Skip to content

Commit 33f4ab8

Browse files
committed
fix(bugs): fixed bugs
1 parent 5e53647 commit 33f4ab8

18 files changed

Lines changed: 117 additions & 74 deletions

File tree

src/app/app.routes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export const routes: Routes = [
3838
},
3939
{
4040
path: 'register',
41+
canActivate: [redirectIfLoggedInGuard],
4142
loadComponent: () =>
4243
import('./features/auth/pages/sign-up/sign-up.component').then((mod) => mod.SignUpComponent),
4344
data: { skipBreadcrumbs: true },

src/app/core/components/breadcrumb/breadcrumb.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="breadcrumbs flex align-items-center gap-2 md:p-5 md:pb-0 xl:p-0">
33
<osf-icon iconClass="fas fa-home"></osf-icon>
44
<p>/</p>
5-
@for (url of parsedUrl(); track url; let l = $last) {
5+
@for (url of parsedUrl(); track $index; let l = $last) {
66
{{ url }}
77
@if (!l) {
88
/

src/app/core/components/header/header.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class HeaderComponent {
4242
command: () => {
4343
this.loaderService.show();
4444
this.actions.logout();
45-
this.router.navigate(['/home']).then(() => window.location.reload());
45+
this.router.navigate(['/']).then(() => window.location.reload());
4646
},
4747
},
4848
];

src/app/core/helpers/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ export * from './http.helper';
22
export * from './i18n.helper';
33
export * from './nav-menu.helper';
44
export * from './types.helper';
5+
export * from './url-param.helper';
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const urlParam = (params: Record<string, string>) => {
2+
return Object.entries(params)
3+
.map((entry) => entry.map((comp) => encodeURIComponent(comp)).join('='))
4+
.join('&');
5+
};
Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,31 @@
11
import { Injectable } from '@angular/core';
22

3+
import { urlParam } from '../helpers/url-param.helper';
4+
35
import { environment } from 'src/environments/environment';
46

57
@Injectable({
68
providedIn: 'root',
79
})
810
export class NavigationService {
911
navigateToSignIn(): void {
10-
const loginUrl = `${environment.casUrl}/login?service=${environment.webUrl}/login`;
12+
const loginUrl = `${environment.casUrl}/login?${urlParam({ service: `${environment.webUrl}/login` })}`;
13+
window.location.href = loginUrl;
14+
}
15+
16+
navigateToOrcidSingIn(): void {
17+
const loginUrl = `${environment.casUrl}/login?${urlParam({
18+
redirectOrcid: 'true',
19+
service: `${environment.webUrl}/login/?next=${encodeURIComponent(environment.webUrl)}`,
20+
})}`;
21+
window.location.href = loginUrl;
22+
}
23+
24+
navigateToInstitutionSignIn(): void {
25+
const loginUrl = `${environment.casUrl}/login?${urlParam({
26+
campaign: 'institution',
27+
service: `${environment.webUrl}/login/?next=${encodeURIComponent(environment.webUrl)}`,
28+
})}`;
1129
window.location.href = loginUrl;
1230
}
1331
}

src/app/features/auth/pages/sign-up/sign-up.component.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ <h2 class="text-center">{{ 'auth.signUp.title' | translate }}</h2>
44

55
<form [formGroup]="signUpForm" class="mt-6" (ngSubmit)="onSubmit()">
66
<div class="flex flex-column gap-3">
7-
<p-button class="btn-full-width" [label]="'auth.signUp.social.orcid' | translate" variant="text" raised>
7+
<p-button
8+
class="btn-full-width"
9+
[label]="'auth.signUp.social.orcid' | translate"
10+
variant="text"
11+
raised
12+
(onClick)="navigateToOrcidSingIn()"
13+
>
814
<img ngSrc="assets/images/orcid.svg" alt="Orchid icon" height="20" width="20" />
915
</p-button>
1016

@@ -14,6 +20,7 @@ <h2 class="text-center">{{ 'auth.signUp.title' | translate }}</h2>
1420
variant="text"
1521
raised
1622
icon="fas fa-landmark fa-lg"
23+
(onClick)="navigateToInstitutionSingIn()"
1724
>
1825
</p-button>
1926
</div>
Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
@use "assets/styles/mixins" as mix;
2-
31
:host {
4-
@include mix.flex-column-center;
2+
display: flex;
3+
align-items: center;
4+
justify-content: center;
55
flex: 1;
66
background: url("/assets/images/dark-blue-gradient.png") center no-repeat;
77
background-size: cover;
88
}
99

1010
.sign-up-container,
1111
.message-container {
12-
@include mix.flex-column;
12+
display: flex;
13+
flex-direction: column;
1314
background: var(--white);
1415
border-radius: 0.6rem;
1516
box-shadow: 0 2px 4px var(--grey-outline);
@@ -22,10 +23,6 @@
2223
}
2324
}
2425

25-
.sign-up-container {
26-
flex: 1;
27-
}
28-
2926
.message-container {
3027
margin: auto;
3128
}

src/app/features/auth/pages/sign-up/sign-up.component.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ import { Divider } from 'primeng/divider';
99
import { Password } from 'primeng/password';
1010

1111
import { CommonModule, NgOptimizedImage } from '@angular/common';
12-
import { Component, OnInit, signal } from '@angular/core';
12+
import { Component, inject, OnInit, signal } from '@angular/core';
1313
import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
1414
import { RouterLink } from '@angular/router';
1515

16+
import { NavigationService } from '@osf/core/services';
1617
import { RegisterUser } from '@osf/features/auth/store';
1718
import { PasswordInputHintComponent, TextInputComponent } from '@osf/shared/components';
1819
import { InputLimits } from '@osf/shared/constants';
@@ -42,14 +43,15 @@ import { environment } from 'src/environments/environment';
4243
styleUrl: './sign-up.component.scss',
4344
})
4445
export class SignUpComponent implements OnInit {
46+
private readonly navigateService = inject(NavigationService);
47+
48+
private readonly actions = createDispatchMap({ registerUser: RegisterUser });
49+
4550
signUpForm = new FormGroup<SignUpForm>({} as SignUpForm);
4651
passwordRegex: RegExp = PASSWORD_REGEX;
4752
inputLimits = InputLimits;
48-
4953
isFormSubmitted = signal(false);
5054

51-
actions = createDispatchMap({ registerUser: RegisterUser });
52-
5355
readonly siteKey = environment.recaptchaSiteKey;
5456

5557
get isPasswordError() {
@@ -105,4 +107,12 @@ export class SignUpComponent implements OnInit {
105107
},
106108
});
107109
}
110+
111+
navigateToOrcidSingIn(): void {
112+
this.navigateService.navigateToOrcidSingIn();
113+
}
114+
115+
navigateToInstitutionSingIn(): void {
116+
this.navigateService.navigateToInstitutionSignIn();
117+
}
108118
}

src/app/features/auth/store/auth.state.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ export class AuthState {
2525

2626
@Action(RegisterUser)
2727
signUp(ctx: StateContext<AuthStateModel>, action: RegisterUser) {
28-
return this.authService.register(action.payload).subscribe();
28+
return this.authService.register(action.payload);
2929
}
3030

3131
@Action(ForgotPassword)
3232
forgotPassword(ctx: StateContext<AuthStateModel>, action: ForgotPassword) {
33-
return this.authService.forgotPassword(action.email).subscribe();
33+
return this.authService.forgotPassword(action.email);
3434
}
3535

3636
@Action(ResetPassword)
3737
resetPassword(ctx: StateContext<AuthStateModel>, { userId, token, newPassword }: ResetPassword) {
38-
return this.authService.resetPassword(userId, token, newPassword).subscribe();
38+
return this.authService.resetPassword(userId, token, newPassword);
3939
}
4040

4141
@Action(SetAuthenticated)

0 commit comments

Comments
 (0)