update can redirect back to what they came from after login

This commit is contained in:
Kenta420 2023-10-05 13:56:04 +07:00
parent 1f4f5b6ad2
commit a12b30998d
3 changed files with 57 additions and 14 deletions

View file

@ -1,4 +1,5 @@
import { Component } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { environment } from 'src/environments/environment';
@Component({
@ -20,8 +21,12 @@ import { environment } from 'src/environments/environment';
standalone: true,
})
export class GoogleButtonComponent {
constructor(private route: ActivatedRoute) {}
loginWithGoogle(): void {
const returnUrl = this.route.snapshot.queryParams['redirectUrl'] || '/';
// redirect to google login in server
window.location.href = environment.api + '/auth/google';
window.location.href =
environment.api + '/auth/google' + '?redirect_to=' + returnUrl;
}
}