Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged in verifiedEmail (pull request coding-blocks#42)
Browse files Browse the repository at this point in the history
VerifiedEmail
sd5869 authored and Varun Hasija committed Feb 20, 2018
2 parents d937ca7 + 15e4fdf commit 166196c
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions routes/oneauth.js
Original file line number Diff line number Diff line change
@@ -22,6 +22,10 @@ router.get('/login', (req, res, next) => {
}
OneAuth.addAuthTokenToDb(grantCode).then((result) => {
//TODO: Handle the case when grant_code is wrong
if(!result.verifiedEmail) {
res.status(405).json({error: "Unverified Email"});
return;
}
if (process.env.NODE_ENV === "production") {
if (req.headers.referer.startsWith('https://hack.codingblocks.com/admin') &&
result.user.role_id !== 1 && result.user.role_id !== 3) {
5 changes: 3 additions & 2 deletions services/oneauth.js
Original file line number Diff line number Diff line change
@@ -15,11 +15,12 @@ const Raven = require ('raven');


const addAuthTokenToDb = function(grant_code) {
let authToken, oauthId;
let authToken, oauthId, verifiedEmail;
return OneAuthRepo.getAuthToken(grant_code).then((result) => {
authToken = result.access_token;
return OneAuthRepo.getUserDetails(authToken);
}).then(result => {
verifiedEmail = result.verifiedemail;
let userObj = {};
oauthId = userObj.oauth_id = result.id;
userObj.access_token = authToken;
@@ -52,7 +53,7 @@ const addAuthTokenToDb = function(grant_code) {
Raven.captureException (err)
});
}
return {authToken, oauthId, user: result, refreshToken: session.refreshToken};
return {authToken, oauthId, user: result, refreshToken: session.refreshToken, verifiedEmail};
});
};

0 comments on commit 166196c

Please sign in to comment.