Skip to content

Commit 13c96dd

Browse files
author
Ajit Kumar
committed
feat(recognize x-auth-token for app login)
1 parent e460321 commit 13c96dd

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

client/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import Theme from 'lib/theme';
1313
import dark from 'themes/dark';
1414
import View from './main.view';
1515

16-
const DOCS_URL = "https://acode-foundation.github.io/acode-plugin-docs/";
16+
const DOCS_URL = 'https://acode-foundation.github.io/acode-plugin-docs/';
1717

1818
window.onload = async () => {
1919
Theme(dark);

server/apis/login.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ route.post('/', async (req, res) => {
5959
maxAge: 1000 * 60 * 60 * 24 * 7, // 1 week
6060
});
6161

62-
res.send({ message: 'Logged in' });
62+
res.send({ message: 'Logged in', token });
6363
} catch (error) {
6464
res.status(500).send(error.message);
6565
}

server/lib/helpers.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ const user = require('../entities/user');
1414
* @returns {Promise<LoggedInUser & User>}
1515
*/
1616
async function getLoggedInUser(req) {
17-
const { token } = req.cookies;
17+
let { token } = req.cookies;
1818

1919
if (!token) {
20-
return null;
20+
token = req.headers['x-auth-token'];
21+
22+
if (!token) {
23+
return null;
24+
}
2125
}
2226

2327
const row = await login.get([login.TOKEN, token]);

0 commit comments

Comments
 (0)