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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user