Skip to content

Commit

Permalink
fix: .auth/me should return null if user is not authentucated
Browse files Browse the repository at this point in the history
  • Loading branch information
manekinekko committed Jun 27, 2020
1 parent 7361bc3 commit f1029af
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app_auth_me/function.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{
"type": "http",
"direction": "out",
"name": "res"
"name": "$return"
}
]
}
24 changes: 16 additions & 8 deletions app_auth_me/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,38 @@ module.exports = async function (context, req) {
const token = null; //req.headers.Cookie.token;

if (!token) {
context.res = response({
return response({
context,
status: 401,
status: 200,
body: {
clientPrincipal: null
}
});
return;
}

var payload;
let payload = null;
try {
payload = jwt.verify(token, jwtKey);
} catch (e) {
if (e instanceof jwt.JsonWebTokenError) {
context.res = response({
return response({
context,
status: 401,
status: 200,
body: {
clientPrincipal: null
}
});
}
context.res = response({
return response({
context,
status: 400,
body: {
clientPrincipal: null
}
});
}

context.res = response({
return response({
context,
status: 200,
body: {
Expand Down

0 comments on commit f1029af

Please sign in to comment.