summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-12-12 13:54:34 +0100
committerTor Andersson <tor@ccxvii.net>2023-12-12 15:18:19 +0100
commit0e770aa13994f18f4d37bdddc670acfd17187e35 (patch)
treea72265b041ae862339890bf09c21773676f74cc9
parentfd29d12bca9b432eb42ec3fecdac28ffdb4393d1 (diff)
downloadserver-0e770aa13994f18f4d37bdddc670acfd17187e35.tar.gz
Improve login page.
-rw-r--r--server.js10
-rw-r--r--views/create.pug72
-rw-r--r--views/join.pug2
-rw-r--r--views/login.pug4
-rw-r--r--views/signup.pug2
5 files changed, 51 insertions, 39 deletions
diff --git a/server.js b/server.js
index ba339fe..3d58e09 100644
--- a/server.js
+++ b/server.js
@@ -381,7 +381,7 @@ app.get('/', function (req, res) {
res.render('index.pug', { user: req.user })
})
-app.get('/create', must_be_logged_in, function (req, res) {
+app.get('/create', function (req, res) {
res.render('create-index.pug', { user: req.user })
})
@@ -399,7 +399,7 @@ app.post('/logout', function (req, res) {
app.get('/login', function (req, res) {
if (req.user)
return res.redirect('/')
- res.render('login.pug', { redirect: req.query.redirect || '/profile' })
+ res.render('login.pug', { redirect: req.query.redirect })
})
app.post('/login', function (req, res) {
@@ -414,7 +414,7 @@ app.post('/login', function (req, res) {
if (!user || is_blacklisted(user.mail) || hash_password(password, user.salt) != user.password)
return setTimeout(() => res.render('login.pug', { flash: "Invalid login." }), 1000)
login_insert(res, user.user_id)
- res.redirect(redirect)
+ res.redirect(redirect || "/profile")
})
app.get('/signup', function (req, res) {
@@ -1598,7 +1598,7 @@ function get_title_page(req, res, title_id) {
for (let title of TITLE_LIST)
app.get('/' + title.title_id, (req, res) => get_title_page(req, res, title.title_id))
-app.get('/create/:title_id', must_be_logged_in, function (req, res) {
+app.get('/create/:title_id', function (req, res) {
let title_id = req.params.title_id
let title = TITLE_TABLE[title_id]
if (!title)
@@ -1606,7 +1606,7 @@ app.get('/create/:title_id', must_be_logged_in, function (req, res) {
res.render('create.pug', {
user: req.user,
title: title,
- limit: check_create_game_limit(req.user),
+ limit: req.user ? check_create_game_limit(req.user) : null,
scenarios: RULES[title_id].scenarios,
})
})
diff --git a/views/create.pug b/views/create.pug
index 7a8a6b8..4e52da4 100644
--- a/views/create.pug
+++ b/views/create.pug
@@ -13,6 +13,9 @@ html
div.logo
+gamecover(title.title_id)
+ if !user
+ p.error You are not logged in!
+
form(method="post" action="/create/"+title.title_id)
if Array.isArray(scenarios)
if scenarios.length > 1
@@ -38,43 +41,48 @@ html
| !{ title.create_html }
- p Notice:
- br
- input(type="text" autocomplete="off" name="notice" size=45 placeholder="What are you looking for?")
+ if user
+ p Notice:
+ br
+ input(type="text" autocomplete="off" name="notice" size=45 placeholder="What are you looking for?")
+
+ p Pace:
+ br
+ label
+ input(type="radio" name="pace" value="0" checked)
+ | Any
- p Pace:
- br
- label
- input(type="radio" name="pace" value="0" checked)
- | Any
+ br
+ label
+ input(type="radio" name="pace" value="1")
+ | #{EMOJI_LIVE} Live
- br
- label
- input(type="radio" name="pace" value="1")
- | #{EMOJI_LIVE} Live
+ br
+ label
+ input(type="radio" name="pace" value="2")
+ | #{EMOJI_FAST} Fast <i>&ndash; many moves per day</i>
- br
- label
- input(type="radio" name="pace" value="2")
- | #{EMOJI_FAST} Fast <i>&ndash; many moves per day</i>
+ br
+ label
+ input(type="radio" name="pace" value="3")
+ | #{EMOJI_SLOW} Slow <i>&ndash; one move per day</i>
- br
- label
- input(type="radio" name="pace" value="3")
- | #{EMOJI_SLOW} Slow <i>&ndash; one move per day</i>
+ p
+ label
+ input(type="checkbox" name="is_random" value="true")
+ | Random player roles
- p
- label
- input(type="checkbox" name="is_random" value="true")
- | Random player roles
+ p
+ label
+ input(type="checkbox" name="is_private" value="true")
+ | Private
- p
- label
- input(type="checkbox" name="is_private" value="true")
- | Private
+ if limit
+ p.error= limit
+ else
+ p
+ button(type="submit") Create
- if limit
- p.error= limit
else
- p
- button(type="submit") Create
+ p <a href="/login">Login</a> or <a href="/signup">sign up</a> to play.
+
diff --git a/views/join.pug b/views/join.pug
index 280e2e6..2fc9287 100644
--- a/views/join.pug
+++ b/views/join.pug
@@ -103,4 +103,4 @@ html
button.hide#start_button(onclick="start()" disabled) Start
if !user && !ready
- p <a href="/login">Login</a> or <a href="/signup">sign up</a> to play this game.
+ p <a href="/login">Login</a> or <a href="/signup">sign up</a> to play.
diff --git a/views/login.pug b/views/login.pug
index 72154f0..a470b59 100644
--- a/views/login.pug
+++ b/views/login.pug
@@ -11,6 +11,10 @@ html
if flash
p.error= flash
+ if redirect
+ p You need to be logged in to view this page!
+ p Log in below, or <a href="/signup">sign up</a> for a free account.
+
if user
p You're already logged in!
else
diff --git a/views/signup.pug b/views/signup.pug
index 70de257..8ce41a2 100644
--- a/views/signup.pug
+++ b/views/signup.pug
@@ -29,7 +29,7 @@ html
br
input(type="email" name="mail" required)
br
- i Your mail address is only used for turn notifications and password recovery.
+ i Your mail address is only used for game notifications and password recovery.
br
i It will not be visible to other players.
p