Skip to content

Commit

Permalink
BG2-2745: Show welcome message in place of auto-login following new a…
Browse files Browse the repository at this point in the history
…ccount registration
  • Loading branch information
bdsl committed Nov 27, 2024
1 parent 0a04c42 commit 059e6bb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/app/login/login.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
text="Donor Login"
></biggive-heading>
</div>
@if (isNewRegistration) {
<p class="welcome-to-big-give">Welcome to Big Give! You are now registered as a donor. Please log in to continue.</p>
}
@if (forgotPassword) {
<div>
<h2 mat-dialog-title>Reset Password</h2>
Expand Down
10 changes: 10 additions & 0 deletions src/app/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ export function isAllowableRedirectPath(redirectParam: string) {
return ! redirectParam.match(/[^a-zA-Z0-9\-_\/]/);
}

export type loginNavigationState = {
/**
* True if we came here as a redirect from the registration form.
*/
newAccountRegistration?: boolean
}

@Component({
selector: 'app-login',
standalone: true,
Expand Down Expand Up @@ -48,6 +55,7 @@ export class LoginComponent implements OnInit, AfterViewInit, OnDestroy{
public pageInitialised = false;
private captchaCode: string | undefined;
protected registerLink: string;
protected isNewRegistration: boolean = false;

constructor(
private readonly formBuilder: FormBuilder,
Expand All @@ -56,6 +64,8 @@ export class LoginComponent implements OnInit, AfterViewInit, OnDestroy{
private readonly router: Router,
@Inject(PLATFORM_ID) private platformId: Object,
) {
const state: loginNavigationState = <loginNavigationState>this.router.getCurrentNavigation()?.extras.state;
this.isNewRegistration = !!state?.newAccountRegistration;
}

ngOnDestroy() {
Expand Down
8 changes: 5 additions & 3 deletions src/app/register/register.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {DomSanitizer, SafeHtml} from "@angular/platform-browser";
import {transferFundsPath} from "../app-routing";
import {WidgetInstance} from "friendly-challenge";
import {flags} from "../featureFlags";
import {isAllowableRedirectPath} from "../login/login.component";
import {isAllowableRedirectPath, loginNavigationState} from "../login/login.component";

@Component({
selector: 'app-register',
Expand Down Expand Up @@ -163,8 +163,10 @@ export class RegisterComponent implements OnInit, OnDestroy, AfterViewInit {
next: () => {
// We can't re-use a captcha code twice, so auto-login won't work right now. For now we just
// redirect to the login form
const newPath = "/login" + '?r=' + encodeURIComponent(this.redirectPath);
window.location.href = newPath;
const state: loginNavigationState = {newAccountRegistration: true};
this.router.navigateByUrl("/login" + '?r=' + encodeURIComponent(this.redirectPath), {
state: state
})
},
error: (error) => {
extractErrorMessage(error);
Expand Down

0 comments on commit 059e6bb

Please sign in to comment.