-
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.
- feat(Microsoft Login): Register and login Teacher (#1713) - feat(Microsoft Login): Register and Login Student (#1717) - refactor(Register User): Extract AbstractRegisterUserComponent (#1719) Co-authored-by: Jonathan Lim-Breitbart <breity10@gmail.com>
- Loading branch information
1 parent
590b3a5
commit 23f8208
Showing
29 changed files
with
381 additions
and
123 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
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
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,53 @@ | ||
import { Router } from '@angular/router'; | ||
import { UserService } from '../services/user.service'; | ||
import { ConfigService } from '../services/config.service'; | ||
import { Directive, OnInit } from '@angular/core'; | ||
import { GoogleUser } from '../modules/google-sign-in/GoogleUser'; | ||
|
||
@Directive() | ||
export abstract class AbstractRegisterUserComponent implements OnInit { | ||
protected googleAuthenticationEnabled: boolean = false; | ||
protected abstract joinFormPath: string; | ||
protected microsoftAuthenticationEnabled: boolean = false; | ||
|
||
constructor( | ||
private configService: ConfigService, | ||
private router: Router, | ||
private userService: UserService | ||
) {} | ||
|
||
ngOnInit(): void { | ||
this.configService.getConfig().subscribe((config) => { | ||
if (config != null) { | ||
this.googleAuthenticationEnabled = this.isSet(config.googleClientId); | ||
this.microsoftAuthenticationEnabled = this.isSet(config.microsoftClientId); | ||
} | ||
}); | ||
} | ||
|
||
private isSet(value: string): boolean { | ||
return value != null && value != ''; | ||
} | ||
|
||
protected googleSignIn(credential: GoogleUser): void { | ||
this.userService.isGoogleIdExists(credential.sub).subscribe((isExists) => { | ||
if (isExists) { | ||
this.router.navigate(['join/googleUserAlreadyExists']); | ||
} else { | ||
this.router.navigate([this.joinFormPath, this.getGoogleFormParams(credential)]); | ||
} | ||
}); | ||
} | ||
|
||
protected signUp(): void { | ||
this.router.navigate([this.joinFormPath, this.getFormParams()]); | ||
} | ||
|
||
protected microsoftSignIn(): void { | ||
window.location.href = `/api/microsoft-login?redirectUrl=${this.joinFormPath}`; | ||
} | ||
|
||
protected abstract getFormParams(): any; | ||
|
||
protected abstract getGoogleFormParams(credential: GoogleUser): any; | ||
} |
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
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
21 changes: 21 additions & 0 deletions
21
...ister-microsoft-user-already-exists/register-microsoft-user-already-exists.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,21 @@ | ||
<mat-card | ||
appearance="outlined" | ||
class="standalone__content standalone__content--sm mat-elevation-z4 center" | ||
> | ||
<mat-card-content> | ||
<h2 class="standalone__title accent" i18n>Create Account</h2> | ||
<p class="mat-subtitle-2" i18n>Hi! This Microsoft user already has a WISE account.</p> | ||
<mat-card-actions fxLayout="row" fxLayoutAlign="center center"> | ||
<button | ||
class="button--social-login button--microsoft" | ||
color="accent" | ||
mat-flat-button | ||
(click)="login()" | ||
> | ||
<img src="assets/img/icons/ms-logo.svg" i18n-alt alt="Microsoft logo" /><ng-container i18n | ||
>Sign in with Microsoft</ng-container | ||
> | ||
</button> | ||
</mat-card-actions> | ||
</mat-card-content> | ||
</mat-card> |
22 changes: 22 additions & 0 deletions
22
...er-microsoft-user-already-exists/register-microsoft-user-already-exists.component.spec.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,22 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { RegisterMicrosoftUserAlreadyExistsComponent } from './register-microsoft-user-already-exists.component'; | ||
import { MatCardModule } from '@angular/material/card'; | ||
|
||
describe('RegisterMicrosoftUserAlreadyExistsComponent', () => { | ||
let component: RegisterMicrosoftUserAlreadyExistsComponent; | ||
let fixture: ComponentFixture<RegisterMicrosoftUserAlreadyExistsComponent>; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [RegisterMicrosoftUserAlreadyExistsComponent], | ||
imports: [MatCardModule] | ||
}); | ||
fixture = TestBed.createComponent(RegisterMicrosoftUserAlreadyExistsComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
10 changes: 10 additions & 0 deletions
10
...egister-microsoft-user-already-exists/register-microsoft-user-already-exists.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,10 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
templateUrl: './register-microsoft-user-already-exists.component.html' | ||
}) | ||
export class RegisterMicrosoftUserAlreadyExistsComponent { | ||
protected login(): void { | ||
window.location.href = `/api/microsoft-login?redirectUrl=/`; | ||
} | ||
} |
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
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
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
Oops, something went wrong.