Skip to content

Commit

Permalink
chg: set flag for store details available
Browse files Browse the repository at this point in the history
  • Loading branch information
wemakshaychavan committed Feb 28, 2023
1 parent 1e495cf commit 7ea8d95
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class AuthenticationService {
//find user with email
data.email = data.email.toLowerCase();

let currentUser = await User.findOne({email:data.email},{enabled:0}).populate([{path:'role'},{path:'organization',select:['name','_id','storeDetails']}]);
let currentUser = await User.findOne({email:data.email},{enabled:0}).populate([{path:'role'},{path:'organization',select:['name','_id','storeDetails']}]).lean();
if (!currentUser) {
throw new UnauthenticatedError(MESSAGES.INVALID_PIN);
}
Expand All @@ -43,8 +43,15 @@ class AuthenticationService {
// create JWT access token
const JWTToken = await AuthenticationJwtToken.getToken(tokenPayload);
delete currentUser.password;
currentUser = currentUser.toJSON(); //TODO: do thi using exec() fn
delete currentUser.password;

if(currentUser.organization ){
if(currentUser.organization.storeDetails.supportDetails){
currentUser.organization.storeDetailsAvailable = true
}else{
currentUser.organization.storeDetailsAvailable = true
}
delete currentUser.organization.storeDetails
}

return { user: currentUser, token: JWTToken };
} catch (err) {
Expand Down

0 comments on commit 7ea8d95

Please sign in to comment.