Browse Source

* Fix 2fa

master
vvandenb 2 years ago
parent
commit
9363512fd9
  1. 2
      Makefile
  2. 1
      back/volume/src/auth/auth.controller.ts
  3. 1
      back/volume/src/auth/auth.service.ts
  4. 2
      front/volume/src/App.svelte
  5. 15
      front/volume/src/Auth.ts
  6. 2
      list

2
Makefile

@ -4,7 +4,7 @@ USER = gavaniwast
all: clean dev all: clean dev
dev: dev:
NODE_ENV="development" docker compose up --build NODE_ENV="development" docker-compose up --build
check: check:
NODE_ENV="check" docker-compose run back --build NODE_ENV="check" docker-compose run back --build

1
back/volume/src/auth/auth.controller.ts

@ -66,7 +66,6 @@ export class AuthController {
@Get('/verify') @Get('/verify')
@UseGuards(AuthenticatedGuard) @UseGuards(AuthenticatedGuard)
@Redirect(`http://${frontHost}:${frontPort}`)
async VerifyEmail (@Profile42() profile: Profile): Promise<void> { async VerifyEmail (@Profile42() profile: Profile): Promise<void> {
const ftId: number = profile.id const ftId: number = profile.id
const user = await this.usersService.findUser(ftId) const user = await this.usersService.findUser(ftId)

1
back/volume/src/auth/auth.service.ts

@ -25,7 +25,6 @@ export class AuthService {
async sendConfirmationEmail (user: User): Promise<void> { async sendConfirmationEmail (user: User): Promise<void> {
user.authToken = Math.floor(10000 + Math.random() * 90000).toString() user.authToken = Math.floor(10000 + Math.random() * 90000).toString()
console.log(`email sent to ${user.email}`)
await this.usersService.save(user) await this.usersService.save(user)
try { try {
await this.mailerService.sendMail({ await this.mailerService.sendMail({

2
front/volume/src/App.svelte

@ -172,6 +172,7 @@
> >
</div> </div>
{:else} {:else}
{#if !failedGameLogIn && !gamePlaying}
<Navbar <Navbar
{clickProfile} {clickProfile}
{clickHistory} {clickHistory}
@ -252,6 +253,7 @@
/> />
</div> </div>
{/if} {/if}
{/if}
<Pong bind:gamePlaying={gamePlaying} bind:this={pong} bind:failedGameLogIn={failedGameLogIn} {appState} {setAppState} bind:resetGameConnection={resetGameConnection} /> <Pong bind:gamePlaying={gamePlaying} bind:this={pong} bind:failedGameLogIn={failedGameLogIn} {appState} {setAppState} bind:resetGameConnection={resetGameConnection} />
{/if} {/if}

15
front/volume/src/Auth.ts

@ -31,13 +31,11 @@ export function login() {
} }
export async function verify() { export async function verify() {
if (get(store).twoFa === true) return; if (get(store).isVerified === true) return;
let email : string; let email : string;
await show_popup("Enter your preferred email adress:\n(defaults to 42 email)") await show_popup("Enter your preferred email adress:\n(defaults to 42 email)")
email = get(content); email = get(content);
if (email == '') if (email !== undefined && email !== '' && email !== 'ok') {
return ;
if (email != 'ok') {
const response = await fetch(API_URL + "/log/email", { const response = await fetch(API_URL + "/log/email", {
method: "POST", method: "POST",
mode: "cors", mode: "cors",
@ -48,21 +46,16 @@ export async function verify() {
if (response.ok) {await show_popup("Email set",false)} if (response.ok) {await show_popup("Email set",false)}
else {await show_popup("Couldn't set Email",false); return } else {await show_popup("Couldn't set Email",false); return }
} }
console.log(API_URL)
const response = await fetch(API_URL + "/log/verify", { const response = await fetch(API_URL + "/log/verify", {
method: "GET", method: "GET",
mode: "cors", mode: "cors",
credentials: "include", credentials: "include",
}); });
console.log(response.ok)
if (response.ok) { if (response.ok) {
console.log("here")
await show_popup("We have sent you an email to verify your account. Check your mailbox!.", false); await show_popup("We have sent you an email to verify your account. Check your mailbox!.", false);
} else { } else {
console.log("there") await show_popup("Email doensn't seem valid", false);
await show_popup("Email doensn't seem valid", false);} }
} }
export function logout() { export function logout() {

2
list

@ -1,2 +0,0 @@
- manage users on deleting channel
- delete
Loading…
Cancel
Save