Skip to content

Commit

Permalink
Merge pull request #1 from d3sandoval/better-mobile-support
Browse files Browse the repository at this point in the history
Better mobile support
  • Loading branch information
Daniel Sandoval authored Jan 17, 2019
2 parents 713933d + c64fb7e commit 2046c01
Show file tree
Hide file tree
Showing 19 changed files with 1,978 additions and 1,618 deletions.
16 changes: 16 additions & 0 deletions api/src/controllers/user.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ async (req: Request, res: Response) => {
const user = new UserModel(req.app.get("db"), req.user.email);
await user.init();
if (user.exists()) {
// update stored metadata
await user.updateMetadata(req.user);
// get team_id to return it
let result: {};
const teamId = user.getTeamId();
if (teamId) {
Expand Down Expand Up @@ -50,4 +53,17 @@ async (req: Request, res: Response) => {
}
});

router.get("/details",
checkJwt,
(req: Request, res: Response) => {
if (req.user) {
res.status(200);
res.json(req.user);
} else {
console.error("req.user is not defined");
res.status(500);
res.send();
}
});

export const UserController: Router = router;
14 changes: 14 additions & 0 deletions api/src/models/user.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,20 @@ export class UserModel {
throw new ModelError(e);
}
}

/**
* Use after init to update auth_metadata with latest from provider
*/
public async updateMetadata(userInfo: IUserInfo) {
if (this.initialized) {
return await this.db.users.save({
id: this.id,
auth_metadata: userInfo
});
}

throw new ModelError(ModelError.NO_INIT);
}

/**
* Use after init to check if user already exists
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.ssl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ services:
nginx:
image: nginx
restart: always
logging:
driver: none
ports:
- "443:443"
- "80:80"
Expand Down
Loading

0 comments on commit 2046c01

Please sign in to comment.