Basic login and register forms. Simple bootstrap frontpage

This commit is contained in:
Jörn-Michael Miehe 2018-12-13 17:07:58 +01:00
parent 492950544e
commit 6cfacc6ec9
4 changed files with 91 additions and 20 deletions

View file

@ -7,6 +7,7 @@ services:
restart: "no" restart: "no"
volumes: volumes:
- "${PWD}/src:/app/src" - "${PWD}/src:/app/src"
- "${PWD}/views:/app/views:ro"
- "${PWD}/public_html:/app/public_html" - "${PWD}/public_html:/app/public_html"
- "${PWD}/fftcg.db:/app/fftcg.db" - "${PWD}/fftcg.db:/app/fftcg.db"
ports: ports:

View file

@ -33,9 +33,9 @@ io.on 'connection', (socket) ->
console.log 'a user disconnected' console.log 'a user disconnected'
return return
socket.on 'login', (msg) -> socket.on 'login', (uname, password) ->
console.log 'message:', msg.uname, msg.password console.log 'message:', uname, password
fftcgdb.adduser msg.uname, msg.password fftcgdb.adduser uname, password
# Create server # Create server
web.listen 3000, -> web.listen 3000, ->

View file

@ -12,10 +12,48 @@ $ ->
# init Socket.IO # init Socket.IO
socket = io() socket = io()
$('form[name="fftcg-login"]').submit ->
data = # login form
uname: $('input[name="uname"]').val() $('form[name="login"]').submit ->
password: $('input[name="password"]').val() # gather form data
uname = $('input[name="uname"]', @)
password = $('input[name="password"]', @)
# transmit form data
socket.emit 'login', uname.val(), password.val()
console.log 'emitted "login", "%s", "%s"', uname.val(), password.val()
# reset form
@reset() @reset()
socket.emit 'login', data # inhibit actual submission
false
# register form
$('form[name="register"]').submit ->
# gather form data
uname = $('input[name="uname"]', @)
password = $('input[name="password"]', @)
confirm = $('input[name="confirm"]', @)
# check form data
if password.val() == confirm.val()
# transmit form data
socket.emit 'register', uname.val(), password.val()
console.log 'emitted "register", "%s", "%s"', uname.val(), password.val()
# reset form
$('input', @).each ->
$(@).removeClass 'is-invalid'
$(@).removeClass 'is-valid'
return
@reset()
else
confirm.val ''
confirm.addClass 'is-invalid'
confirm.focus()
# inhibit actual submission
false false

View file

@ -1,18 +1,50 @@
doctype html doctype html
html html
head head
title Crafty Things title Crafty Things
script(src='/index.bundle.js') script(src='/index.bundle.js')
body body
header.jumbotron.jumbotron-fluid.py-4.bg-primary.text-light.text-center
div.container
h1 Hello World! h1 Hello World!
h2 App under development, please don't send valuable data! h2 App under development, please don't send valuable data!
form(name="fftcg-login" method="post" action="#")
fieldset div.container
legend Login-Details div.row
div
label(for="uname") Username: div.col-md-6
input(name="uname" required) h3 Yavook!FFTCG
p Lorem ipsum dolor sit amet
div.col-md-3
h3 Login
form(name="login")
div.form-group
label(for="uname") User name:
input.form-control(name="uname" required)
div.form-group
label(for="password") Password: label(for="password") Password:
input(name="password", type="password", placeholder="6 digits, a combination of numbers and letters" required) input.form-control(name="password" type="password" required)
div
input(name="login" type="submit" value="Login") div.form-group
button.btn.btn-primary(type="submit") Login
div.col-md-3
h3 Register
form(name="register")
div.form-group
label(for="uname") User name:
input.form-control(name="uname" required)
div.invalid-feedback User name not available.
div.form-group
label(for="password") Password:
input.form-control(name="password" type="password" required)
label(for="confirm") Confirm password:
input.form-control(name="confirm" type="password")
button.btn.btn-primary(type="submit") Register