Add login and signup
This commit is contained in:
23
static/js/controllers/login_controller.js
Normal file
23
static/js/controllers/login_controller.js
Normal file
@ -0,0 +1,23 @@
|
||||
import { Controller } from "../vendors/stimulus.js"
|
||||
import { sendData } from "../webSocketsCli.js"
|
||||
|
||||
export default class extends Controller {
|
||||
|
||||
static targets = [ "email", "password" ]
|
||||
|
||||
/**
|
||||
* Send form from login page
|
||||
* @param {Event} event
|
||||
* @return {void}
|
||||
*/
|
||||
sendFormLogin(event) {
|
||||
event.preventDefault();
|
||||
sendData({
|
||||
action: 'Login',
|
||||
data: {
|
||||
email: this.emailTarget.value,
|
||||
password: this.passwordTarget.value
|
||||
}
|
||||
}, window.myWebSocket);
|
||||
}
|
||||
}
|
@ -19,4 +19,16 @@ export default class extends Controller {
|
||||
}
|
||||
}, window.myWebSocket);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send message to Logout
|
||||
* @param {Event} event
|
||||
* @return {void}
|
||||
*/
|
||||
logout(event) {
|
||||
sendData({
|
||||
action: 'Logout',
|
||||
data: {}
|
||||
}, window.myWebSocket);
|
||||
}
|
||||
}
|
||||
|
25
static/js/controllers/signup_controller.js
Normal file
25
static/js/controllers/signup_controller.js
Normal file
@ -0,0 +1,25 @@
|
||||
import { Controller } from "../vendors/stimulus.js"
|
||||
import { sendData } from "../webSocketsCli.js"
|
||||
|
||||
export default class extends Controller {
|
||||
|
||||
static targets = [ "username", "email", "password", "passwordConfirm" ]
|
||||
|
||||
/**
|
||||
* Send form from login page
|
||||
* @param {Event} event
|
||||
* @return {void}
|
||||
*/
|
||||
sendFormSignup(event) {
|
||||
event.preventDefault();
|
||||
sendData({
|
||||
action: 'Signup',
|
||||
data: {
|
||||
username: this.usernameTarget.value,
|
||||
email: this.emailTarget.value,
|
||||
password: this.passwordTarget.value,
|
||||
password_confirm: this.passwordConfirmTarget.value
|
||||
}
|
||||
}, window.myWebSocket);
|
||||
}
|
||||
}
|
@ -2,6 +2,9 @@ import {connect, startEvents} from './webSocketsCli.js';
|
||||
import { Application } from "./vendors/stimulus.js"
|
||||
import navbarController from "./controllers/navbar_controller.js"
|
||||
import todoController from "./controllers/todo_controller.js"
|
||||
import loginController from "./controllers/login_controller.js"
|
||||
import signupController from "./controllers/signup_controller.js"
|
||||
|
||||
/*
|
||||
INITIALIZATION
|
||||
*/
|
||||
@ -15,3 +18,5 @@ window.Stimulus = Application.start();
|
||||
// Register all controllers
|
||||
Stimulus.register("navbar", navbarController);
|
||||
Stimulus.register("todo", todoController);
|
||||
Stimulus.register("login", loginController);
|
||||
Stimulus.register("signup", signupController);
|
||||
|
Reference in New Issue
Block a user