diff options
Diffstat (limited to 'app/Controllers/Http')
-rw-r--r-- | app/Controllers/Http/UserController.js | 12 |
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", |