aboutsummaryrefslogtreecommitdiffstats
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
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
-rw-r--r--README.md3
-rw-r--r--app/Controllers/Http/UserController.js12
-rw-r--r--package.json1
-rw-r--r--yarn.lock5
4 files changed, 13 insertions, 8 deletions
diff --git a/README.md b/README.md
index 440b402..abec164 100644
--- a/README.md
+++ b/README.md
@@ -2,8 +2,7 @@
2Unofficial Franz server replacement for use with the Ferdi Client. 2Unofficial Franz server replacement for use with the Ferdi Client.
3 3
4## Features 4## Features
5- [x] User registration 5- [x] User registration and login
6- [ ] User login (not yet functional)
7- [x] Service creation, download and listing 6- [x] Service creation, download and listing
8- [ ] Service removing 7- [ ] Service removing
9- [ ] Functioning service store 8- [ ] Functioning service store
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",
diff --git a/package.json b/package.json
index 2c8179f..aeba103 100644
--- a/package.json
+++ b/package.json
@@ -25,6 +25,7 @@
25 "@adonisjs/ignitor": "^2.0.8", 25 "@adonisjs/ignitor": "^2.0.8",
26 "@adonisjs/lucid": "^6.1.3", 26 "@adonisjs/lucid": "^6.1.3",
27 "atob": "^2.1.2", 27 "atob": "^2.1.2",
28 "node-fetch": "^2.6.0",
28 "pg": "^7.12.1", 29 "pg": "^7.12.1",
29 "sqlite3": "^4.1.0", 30 "sqlite3": "^4.1.0",
30 "uuid": "^3.3.3" 31 "uuid": "^3.3.3"
diff --git a/yarn.lock b/yarn.lock
index d9558e7..26f1e52 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2213,6 +2213,11 @@ node-exceptions@^3.0.0:
2213 resolved "https://registry.yarnpkg.com/node-exceptions/-/node-exceptions-3.0.0.tgz#48b8e10da71370845ef1af583778139527308d11" 2213 resolved "https://registry.yarnpkg.com/node-exceptions/-/node-exceptions-3.0.0.tgz#48b8e10da71370845ef1af583778139527308d11"
2214 integrity sha512-pFhMAqdN1avrFwtZs66HxYiVnbnH9wjXB4m8IKs5Z9+r7U5voqxT+EDbVkRfge+V7JnkOgKhN4HfKBn1o5g9Wg== 2214 integrity sha512-pFhMAqdN1avrFwtZs66HxYiVnbnH9wjXB4m8IKs5Z9+r7U5voqxT+EDbVkRfge+V7JnkOgKhN4HfKBn1o5g9Wg==
2215 2215
2216node-fetch@^2.6.0:
2217 version "2.6.0"
2218 resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd"
2219 integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==
2220
2216node-pre-gyp@^0.11.0: 2221node-pre-gyp@^0.11.0:
2217 version "0.11.0" 2222 version "0.11.0"
2218 resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.11.0.tgz#db1f33215272f692cd38f03238e3e9b47c5dd054" 2223 resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.11.0.tgz#db1f33215272f692cd38f03238e3e9b47c5dd054"