Browse Source

2fa return route changed to get, fixed profile after login and removed username from friends window

master
nicolas-arnaud 2 years ago
parent
commit
2a6735fefa
  1. 9
      back/src/auth/auth.controller.ts
  2. 6
      back/src/auth/mails/confirm.hbs
  3. 2
      front/src/App.svelte
  4. 4
      front/src/components/Friends.svelte

9
back/src/auth/auth.controller.ts

@ -7,7 +7,8 @@ import {
Req,
Post,
Body,
BadRequestException
BadRequestException,
Param
} from '@nestjs/common'
import { Response, Request } from 'express'
@ -60,10 +61,10 @@ export class AuthController {
await this.authService.sendConfirmationEmail(user)
}
@Post('/verify')
@Get('/verify/:code')
@Redirect(`http://${frontHost}:${frontPort}`)
async Verify (@Body() body: any): Promise<void> {
await this.authService.verifyAccount(body.code)
async Verify (@Param("code") code: string): Promise<void> {
await this.authService.verifyAccount(code)
}
@Get('profile')

6
back/src/auth/mails/confirm.hbs

@ -8,8 +8,8 @@
<body>
<h2>Hello {{username}}! </h2>
<p> Once you clicked on the next verify button, you will have access to the app</p>
<form action="http://localhost:3001/log/verify" method="post">
<button type="submit" name="code" value={{code}}>Verify</button>
</form>
<button onclick="window.location.href = 'http://localhost:3001/log/verify/{{code}}';">
VERIFY
</button>
</body>
</html>

2
front/src/App.svelte

@ -89,7 +89,7 @@
onMount(() => {
if (window.location.pathname === "/profile")
history.replaceState({ appState: APPSTATE.PROFILE }, "", APPSTATE.PROFILE);
appState = APPSTATE.PROFILE;
else
history.replaceState({ appState: "" }, "", "/");
window.onpopstate = (e: PopStateEvent) => {

4
front/src/components/Friends.svelte

@ -72,7 +72,7 @@
<div class="overlay">
<div class="friends" on:click|stopPropagation on:keydown|stopPropagation>
<div>
<h2>{$store.username} friends:</h2>
<h2>Friends:</h2>
{#if friends.length > 0}
<div class="friends-list">
{#each friends as friend}
@ -88,7 +88,7 @@
{:else}
<p>No friends to display</p>
{/if}
<h2>{$store.username} invits:</h2>
<h2>Invitations:</h2>
{#if invits.length > 0}
<div class="invits-list">
{#each invits as invit}

Loading…
Cancel
Save