aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorLibravatar vantezzen <properly@protonmail.com>2019-08-23 14:04:09 +0200
committerLibravatar vantezzen <properly@protonmail.com>2019-08-23 14:04:09 +0200
commitea47eb9394e731aea2ae17c6edb00948555ec151 (patch)
tree1bbc316eec5a9ce5d293426d5a2b9922d2a2eebb /app
parentMerge branch 'master' of https://github.com/vantezzen/ferdi-server (diff)
downloadferdium-server-ea47eb9394e731aea2ae17c6edb00948555ec151.tar.gz
ferdium-server-ea47eb9394e731aea2ae17c6edb00948555ec151.tar.zst
ferdium-server-ea47eb9394e731aea2ae17c6edb00948555ec151.zip
Fix user login
Diffstat (limited to 'app')
-rw-r--r--app/Controllers/Http/UserController.js12
1 files changed, 6 insertions, 6 deletions
diff --git a/app/Controllers/Http/UserController.js b/app/Controllers/Http/UserController.js
index 88f7ecd..062e16f 100644
--- a/app/Controllers/Http/UserController.js
+++ b/app/Controllers/Http/UserController.js
@@ -32,21 +32,21 @@ class UserController {
32 response, 32 response,
33 auth 33 auth
34 }) { 34 }) {
35 const authHeader = atob(request.header('Authorization')).split(':'); 35 const authHeader = atob(request.header('Authorization').replace('Basic ', '')).split(':');
36 36
37 let user = (await User.query().where('email', authHeader[0]).limit(1).fetch()).toJSON(); 37 let user = (await User.query().where('email', authHeader[0]).first());
38 if (!user[0] || !user[0].email) { 38 if (!user || !user.email) {
39 return response.status(401).send({ 39 return response.status(401).send({
40 "message": "User credentials not valid", 40 "message": "User credentials not valid (Invalid mail)",
41 "code": "invalid-credentials", 41 "code": "invalid-credentials",
42 "status": 401 42 "status": 401
43 }); 43 });
44 } 44 }
45 45
46
46 let token; 47 let token;
47 try { 48 try {
48 // TODO: Login is currently not working as the password is incorrect 49 token = await auth.attempt(user.email, authHeader[1])
49 token = await auth.attempt(user[0].id, authHeader[1])
50 } catch (e) { 50 } catch (e) {
51 return response.status(401).send({ 51 return response.status(401).send({
52 "message": "User credentials not valid", 52 "message": "User credentials not valid",