-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Login with username and password (#70)
* initial login UI * Login is taking shape * Normal login works * Add way to check for expired tokens * Add method to check if we should renew the token * MFA WORKS * translate 2fa modal * Better 2fa input fields * Better button title * update translations * Start on new sign-up page * Create component for pronouns input * Create component for languages input * Add country input component * Finish register ui * Add thank you section * Start on nag about verifying emails * Allow for re-sending verification email * translate message for email verification * WIP password resetting * Proxy api to make it more like prod * Translation update * Request password reset from user settings * Password reset from login system done * Cleanup and bugfixing * Add types to sync handler * Ensure youtube works in new settings page
- Loading branch information
Showing
64 changed files
with
1,565 additions
and
293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Simple script that helps me copy translations and save our translators some time if I'm just copying. | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const rootDir = path.resolve(__dirname, 'src', 'assets', 'i18n'); | ||
const jsonFiles = fs.readdirSync(rootDir).filter((file) => file.endsWith('.json')); | ||
|
||
for (const file of jsonFiles) { | ||
const filePath = path.resolve(rootDir, file); | ||
const json = fs.readFileSync(filePath, 'utf8'); | ||
const obj = JSON.parse(json); | ||
|
||
if (obj.navbar?.login?.discord) { | ||
obj.login = { ...obj.login }; | ||
obj.login.provider = {...obj.login.provider }; | ||
|
||
obj.login.provider.discord = obj.navbar.login.discord; | ||
} | ||
|
||
if (obj.navbar?.login?.twitch) { | ||
obj.login = { ...obj.login }; | ||
obj.login.provider = {...obj.login.provider }; | ||
|
||
obj.login.provider.twitch = obj.navbar.login.twitch; | ||
} | ||
|
||
if (obj.navbar?.login?.google) { | ||
obj.login = { ...obj.login }; | ||
obj.login.provider = {...obj.login.provider }; | ||
|
||
obj.login.provider.google = obj.navbar.login.google; | ||
} | ||
|
||
fs.writeFileSync(filePath, JSON.stringify(obj, null, 2)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/app/_layout/header-bar/header-bar-verify-email/header-bar-verify-email.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<div *ngIf="show" class="verify-host"> | ||
<div> | ||
{{ 'navbar.email-verification.message' | translate }} | ||
</div> | ||
|
||
<div class="buttons"> | ||
<button type="button" class="button is-info" [disabled]="!canPressButton" (click)="requestNewEmail()"> | ||
{{ 'navbar.email-verification.request-btn' | translate }} | ||
</button> | ||
</div> | ||
</div> |
10 changes: 10 additions & 0 deletions
10
src/app/_layout/header-bar/header-bar-verify-email/header-bar-verify-email.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.verify-host { | ||
padding: 10px; | ||
} | ||
|
||
div { | ||
display: flex; | ||
flex-wrap: wrap; | ||
justify-content: space-between; | ||
gap: 0.5em; | ||
} |
38 changes: 38 additions & 0 deletions
38
src/app/_layout/header-bar/header-bar-verify-email/header-bar-verify-email.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Component } from '@angular/core'; | ||
import { UserService } from '../../../../services/user.service'; | ||
import { AuthService } from '../../../../services/auth.service'; | ||
|
||
@Component({ | ||
selector: 'app-header-bar-verify-email', | ||
templateUrl: './header-bar-verify-email.component.html', | ||
styleUrls: ['./header-bar-verify-email.component.scss'] | ||
}) | ||
export class HeaderBarVerifyEmailComponent { | ||
|
||
canPressButton = true; | ||
|
||
constructor( | ||
private authService: AuthService, | ||
private userService: UserService, | ||
) { } | ||
|
||
requestNewEmail() { | ||
this.canPressButton = false; | ||
this.authService.requestNewVerificationEmail().subscribe({ | ||
next({ status }) { | ||
console.log(status); | ||
alert('Email sent!'); | ||
}, | ||
|
||
error(err: any) { | ||
console.log(err); | ||
alert('Something went wrong! Please try again later. '); | ||
} | ||
}); | ||
} | ||
|
||
get show(): boolean { | ||
return this.userService.user && !this.userService.user.emailVerified; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
<header> | ||
<app-header-bar-display-name></app-header-bar-display-name> | ||
<app-header-bar-verify-email></app-header-bar-verify-email> | ||
<app-header-bar-cookies *ngIf="showCookieBar" (visibilityUpdated)="showCookieBar = $event"></app-header-bar-cookies> | ||
<app-header-bar-nav></app-header-bar-nav> | ||
</header> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/app/auth/forgot-password/forgot-password.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<section class="section container"> | ||
<h1 class="title">Reset your password!</h1> | ||
|
||
<div class="notification" [class]="notificationClass" *ngIf="errorTranslationKey"> | ||
<button class="delete" (click)="errorTranslationKey = null"></button> | ||
{{ errorTranslationKey | translate }} | ||
</div> | ||
|
||
<p>{{ 'auth.passwordReset.instructions' | translate }}</p> | ||
|
||
<div class="columns"> | ||
<div class="column is-three-fifths is-offset-one-fifth"> | ||
<form (submit)="requestNewPassword($event.target)"> | ||
<fieldset [disabled]="loading"> | ||
|
||
<div class="field"> | ||
<label class="label">{{ 'user.settings.email.label' | translate }}</label> | ||
<div class="control has-icons-left"> | ||
<input class="input" required type="email" placeholder="[email protected]" name="email" [(ngModel)]="email"> | ||
<span class="icon is-small is-left"> | ||
<fa-icon [icon]="iconUser"></fa-icon> | ||
</span> | ||
</div> | ||
</div> | ||
|
||
<div class="control"> | ||
<button type="submit" style="margin-right: 1rem" | ||
[ngClass]="{'is-loading': loading}" | ||
class="button is-primary">{{ 'auth.passwordReset.request' | translate }}</button> | ||
</div> | ||
|
||
</fieldset> | ||
</form> | ||
</div> | ||
</div> | ||
</section> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { Component } from '@angular/core'; | ||
import { faEnvelope } from '@fortawesome/free-solid-svg-icons'; | ||
import { passwordResetErrorToMessage } from '../../../utils/authHelpers'; | ||
import { firstValueFrom } from 'rxjs'; | ||
import { AuthService } from '../../../services/auth.service'; | ||
|
||
@Component({ | ||
selector: 'app-forgot-password', | ||
templateUrl: './forgot-password.component.html', | ||
styleUrls: ['./forgot-password.component.scss'] | ||
}) | ||
export class ForgotPasswordComponent { | ||
iconUser = faEnvelope; | ||
|
||
errorTranslationKey: string | null = null; | ||
notificationClass = 'is-danger'; | ||
|
||
loading = false; | ||
email = ''; | ||
|
||
constructor( | ||
private authService: AuthService, | ||
) { } | ||
|
||
async requestNewPassword(form: HTMLFormElement) { | ||
if (!form.reportValidity()) { | ||
return; | ||
} | ||
|
||
try { | ||
this.loading = true; | ||
|
||
const { status } = await firstValueFrom(this.authService.requestPasswordReset(this.email)); | ||
|
||
if (status === 'PASSWORD_RESET_SENT') { | ||
this.notificationClass = 'is-success'; | ||
this.errorTranslationKey = 'auth.passwordReset.requested'; | ||
this.email = ''; | ||
} else { | ||
this.errorTranslationKey = 'You should never see this message. If you do, let me know what you did.'; | ||
} | ||
|
||
} catch (e: any) { | ||
console.log(e.error); | ||
this.notificationClass = 'is-danger'; | ||
this.errorTranslationKey = passwordResetErrorToMessage(e); | ||
} finally { | ||
this.loading = false; | ||
} | ||
} | ||
|
||
get title(): string { | ||
return 'Forgot your password'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,80 @@ | ||
<p>login works!</p> | ||
<section class="section container"> | ||
<h1 class="title">{{ 'login.title' | translate }}</h1> | ||
|
||
<div class="notification is-danger" *ngIf="loginError == 'USERNAME_PASSWORD_INCORRECT'"> | ||
<button class="delete" (click)="loginError = null"></button> | ||
The entered username and password are incorrect. | ||
</div> | ||
|
||
<div class="notification is-danger" *ngIf="loginError == 'MFA_INVALID'"> | ||
<button class="delete" (click)="loginError = null"></button> | ||
2FA code is not valid. | ||
</div> | ||
|
||
<div class="columns"> | ||
<div class="column is-three-fifths is-offset-one-fifth"> | ||
<form action=""> | ||
|
||
<fieldset [disabled]="loading"> | ||
<div class="field"> | ||
<label class="label">{{ 'user.settings.username.label' | translate }}</label> | ||
<div class="control has-icons-left"> | ||
<input class="input" type="text" placeholder="OengusIO" name="username" [(ngModel)]="loginData.username"> | ||
<span class="icon is-small is-left"> | ||
<fa-icon [icon]="iconUser"></fa-icon> | ||
</span> | ||
</div> | ||
</div> | ||
|
||
<app-element-password-input [(password)]="loginData.password"></app-element-password-input> | ||
|
||
<div class="field" *ngIf="mfaNeeded"> | ||
<label class="label">{{ 'login.2fa.label' | translate }}</label> | ||
<div class="control"> | ||
<input class="input" | ||
type="text" | ||
placeholder="000000" | ||
inputmode="numeric" | ||
pattern="[0-9]*" | ||
name="2fa" | ||
[(ngModel)]="loginData.twoFactorCode" /> | ||
</div> | ||
</div> | ||
|
||
<div class="control"> | ||
<button type="submit" style="margin-right: 1rem" | ||
[ngClass]="{'is-loading': loading}" | ||
(click)="performLogin()" | ||
class="button is-primary">{{'login.button' | translate}}</button> | ||
|
||
<a [routerLink]="'/forgot-password' | localize">{{ 'login.forgotPass' | translate }}</a> | ||
</div> | ||
</fieldset> | ||
|
||
</form> | ||
</div> | ||
</div> | ||
|
||
<hr/> | ||
<h2 class="subtitle"> | ||
{{ 'login.provider.title' | translate }} | ||
</h2> | ||
|
||
<div class="buttons is-centered are-large"> | ||
<a [href]="authService.getDiscordAuthUri()" class="button is-discord"> | ||
<span class="icon"> | ||
<fa-icon [icon]="iconDiscord"></fa-icon> | ||
</span> | ||
<span>{{ 'login.provider.discord' | translate }}</span> | ||
</a> | ||
<a [href]="authService.getTwitchAuthUrl()" class="button is-twitch"> | ||
<span class="icon"> | ||
<fa-icon [icon]="iconTwitch"></fa-icon> | ||
</span> | ||
<span>{{ 'login.provider.twitch' | translate }}</span> | ||
</a> | ||
<!--<button class="button is-static"> | ||
{{ 'login.provider.google' | translate }} | ||
</button>--> | ||
</div> | ||
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
Oops, something went wrong.