Skip to content

Commit 4367c1a

Browse files
committed
Add user friendly handling of websignup failure and success
1 parent 659fbc1 commit 4367c1a

File tree

4 files changed

+172
-14
lines changed

4 files changed

+172
-14
lines changed

app/Controllers/Http/UserController.js

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,9 @@ class UserController {
9090
async websignup({ request, response, auth }) {
9191
if (Env.get('IS_REGISTRATION_ENABLED') == 'false') {
9292
// eslint-disable-line eqeqeq
93-
return response.status(401).send({
94-
message: 'Registration is disabled on this server',
95-
status: 401,
96-
});
93+
return response.status(401).send(
94+
'Registration is disabled on this server'
95+
);
9796
}
9897

9998
// Validate user input
@@ -105,11 +104,7 @@ class UserController {
105104
});
106105

107106
if (validation.fails()) {
108-
return response.status(401).send({
109-
message: 'Invalid POST arguments',
110-
messages: validation.messages(),
111-
status: 401,
112-
});
107+
return response.redirect('/websignupretry');
113108
}
114109

115110
const data = request.only(['firstname', 'lastname', 'email', 'password']);
@@ -130,16 +125,15 @@ class UserController {
130125
lastname: data.lastname,
131126
});
132127
} catch (e) {
133-
return response.status(401).send({
134-
message: 'E-Mail Address already in use',
135-
status: 401,
136-
});
128+
return response.status(401).send(
129+
'E-Mail Address already in use'
130+
);
137131
}
138132

139133
await auth.generate(user);
140134

141135
// Redirect user to login page, confirmaiton would be nice
142-
return response.redirect('/user/login');
136+
return response.redirect('/user/signuplogin');
143137
}
144138

145139
// Login using an existing user
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
@layout('layouts.v2')
2+
3+
@section('content')
4+
<div class="w-screen bg-purple-200 flex items-center justify-center">
5+
<form class="w-full max-w-sm bg-white shadow-md rounded px-8 pt-6 pb-8 mb-4"
6+
action="{{ route('login') }}" method="POST">
7+
<h1 class="text-gray-700 text-center text-2xl pb-5">
8+
Signup successful please login
9+
</h1>
10+
11+
@if(flashMessage('error'))
12+
<div class="bg-orange-100 border-l-4 border-orange-500 text-orange-700 p-4">
13+
{{ flashMessage('error') }}
14+
</div>
15+
@endif
16+
@if(old('message'))
17+
<div class="bg-orange-100 border-l-4 border-orange-500 text-orange-700 p-4">
18+
{{ old('message') }}
19+
</div>
20+
@endif
21+
22+
{{ csrfField() }}
23+
<div class="mb-4">
24+
<label class="block text-gray-700 text-sm font-bold mb-2" for="username">
25+
E-Mail
26+
</label>
27+
<input
28+
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
29+
id="mail"
30+
name="mail"
31+
type="text"
32+
placeholder="E-Mail"
33+
value="{{ old('mail', '') }}"
34+
required>
35+
</div>
36+
<div class="mb-6">
37+
<label class="block text-gray-700 text-sm font-bold mb-2" for="password">
38+
Password
39+
</label>
40+
<input
41+
class="shadow appearance-none rounded w-full py-2 px-3 text-gray-700 mb-3 leading-tight focus:outline-none focus:shadow-outline"
42+
id="password"
43+
type="password"
44+
name="password"
45+
placeholder="*****"
46+
autocomplete="current-password"
47+
required>
48+
</div>
49+
<button
50+
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline"
51+
type="submit">
52+
Sign In
53+
</button>
54+
<p class="text-gray-600 text-sm text-center py-2">
55+
By logging in, you accept the <a href="/terms">terms of service</a> and <a href="/privacy">privacy policy</a>. This website uses cookies to log you in.
56+
</p>
57+
<div class="text-center">
58+
<a class="w-full font-bold text-sm text-blue-500 hover:text-blue-800" href="/user/forgot">
59+
Forgot my Password
60+
</a>
61+
</div>
62+
<div class="text-center">
63+
<a class="w-full font-bold text-sm text-blue-500 hover:text-blue-800" href="../import">
64+
Import your Franz/Ferdi account
65+
</a>
66+
</div>
67+
</form>
68+
</div>
69+
@endsection
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
@layout('layouts.v2')
2+
3+
@section('content')
4+
<div class="w-screen bg-purple-200 flex items-center justify-center">
5+
<form class="w-full max-w-sm bg-white shadow-md rounded px-8 pt-6 pb-8 mb-4"
6+
action="/websignup" method="POST">
7+
<h1 class="text-gray-700 text-center text-2xl pb-5">
8+
Error during signup, please try again
9+
</h1>
10+
<p class="text-gray-600 text-sm text-center py-2">
11+
Please provide your details so your Ferdium account can be created.
12+
</p>
13+
14+
@if(flashMessage('error'))
15+
<div class="bg-orange-100 border-l-4 border-orange-500 text-orange-700 p-4">
16+
{{ flashMessage('error') }}
17+
</div>
18+
@endif
19+
@if(old('message'))
20+
<div class="bg-orange-100 border-l-4 border-orange-500 text-orange-700 p-4">
21+
{{ old('message') }}
22+
</div>
23+
@endif
24+
25+
<div class="mb-4">
26+
<label class="block text-gray-700 text-sm font-bold mb-2" for="firstname">
27+
First Name
28+
</label>
29+
<input
30+
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
31+
id="firstname"
32+
name="firstname"
33+
type="text"
34+
placeholder="First Name"
35+
value="{{ old('firstname', '') }}"
36+
required>
37+
</div>
38+
<div class="mb-4">
39+
<label class="block text-gray-700 text-sm font-bold mb-2" for="lastname">
40+
Last Name
41+
</label>
42+
<input
43+
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
44+
id="lastname"
45+
name="lastname"
46+
type="text"
47+
placeholder="Last Name"
48+
value="{{ old('lastname', '') }}"
49+
required>
50+
</div>
51+
<div class="mb-4">
52+
<label class="block text-gray-700 text-sm font-bold mb-2" for="email">
53+
E-Mail
54+
</label>
55+
<input
56+
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
57+
id="email"
58+
name="email"
59+
type="text"
60+
placeholder="E-Mail"
61+
value="{{ old('email', '') }}"
62+
required>
63+
</div>
64+
<div class="mb-6">
65+
<label class="block text-gray-700 text-sm font-bold mb-2" for="password">
66+
Password
67+
</label>
68+
<input
69+
class="shadow appearance-none rounded w-full py-2 px-3 text-gray-700 mb-3 leading-tight focus:outline-none focus:shadow-outline"
70+
id="password"
71+
type="password"
72+
name="password"
73+
placeholder="*****"
74+
autocomplete="current-password"
75+
required>
76+
</div>
77+
<button
78+
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline"
79+
type="submit">
80+
Signup
81+
</button>
82+
<p class="text-gray-600 text-sm text-center py-2">
83+
By signing up for your Franz/Ferdi account, you accept the <a href="/terms">terms of service</a> and <a href="/privacy">privacy
84+
policy</a>
85+
</p>
86+
<div class="text-center">
87+
<a class="w-full font-bold text-sm text-blue-500 hover:text-blue-800" href="/user/login">
88+
Login to an existing account
89+
</a>
90+
</div>
91+
</form>
92+
</div>
93+
@endsection

start/routes.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ if (Env.get('IS_DASHBOARD_ENABLED') !== 'false') {
6262
Route.group(() => {
6363
// Auth
6464
Route.get('login', ({ view }) => view.render('dashboard.login')).middleware('guest');
65+
Route.get('signuplogin', ({ view }) => view.render('dashboard.signuplogin')).middleware('guest');
6566
Route.post('login', 'DashboardController.login').middleware('guest').as('login');
6667

6768
// Reset password
@@ -121,6 +122,7 @@ Route.get('import', ({ view }) => view.render('others.import'));
121122
// Ferdium account signup
122123
Route.post('websignup', 'UserController.websignup');
123124
Route.get('websignup', ({ view }) => view.render('others.websignup'));
125+
Route.get('websignupretry', ({ view }) => view.render('others.websignupretry'));
124126

125127
// Legal documents
126128
Route.get('terms', ({ response }) => response.redirect('/terms.html'));

0 commit comments

Comments
 (0)