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

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

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

2
front/src/App.svelte

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

4
front/src/components/Friends.svelte

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

Loading…
Cancel
Save