remove google and oauth login
This commit is contained in:
@@ -11,12 +11,4 @@ server {
|
||||
location /api/ {
|
||||
proxy_pass http://backend:8080;
|
||||
}
|
||||
|
||||
location /oauth2/ {
|
||||
proxy_pass http://backend:8080;
|
||||
}
|
||||
|
||||
location /login/ {
|
||||
proxy_pass http://backend:8080;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,5 @@
|
||||
"/api": {
|
||||
"target": "http://127.0.0.1:8080",
|
||||
"secure": false
|
||||
},
|
||||
"/oauth2": {
|
||||
"target": "http://127.0.0.1:8080",
|
||||
"secure": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,10 +14,6 @@ export const routes: Routes = [
|
||||
loadComponent: () => import('./auth/register/register.component').then(m => m.RegisterComponent),
|
||||
canActivate: [LoginGuard],
|
||||
},
|
||||
{
|
||||
path: 'oauth2/callback',
|
||||
loadComponent: () => import('./auth/oauth-callback/oauth-callback.component').then(m => m.OAuthCallbackComponent),
|
||||
},
|
||||
{
|
||||
path: 'dashboard',
|
||||
loadComponent: () => import('./dashboard/dashboard.component').then(m => m.DashboardComponent),
|
||||
|
||||
@@ -6,7 +6,6 @@ import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { MatDividerModule } from '@angular/material/divider';
|
||||
import { AuthService } from '../../core/services/auth.service';
|
||||
import { NgIf } from '@angular/common';
|
||||
|
||||
@@ -16,7 +15,7 @@ import { NgIf } from '@angular/common';
|
||||
imports: [
|
||||
RouterLink, ReactiveFormsModule, NgIf,
|
||||
MatCardModule, MatFormFieldModule, MatInputModule, MatButtonModule,
|
||||
MatProgressSpinnerModule, MatDividerModule,
|
||||
MatProgressSpinnerModule,
|
||||
],
|
||||
template: `
|
||||
<div class="min-h-screen flex items-center justify-center bg-gray-50 px-4">
|
||||
@@ -48,19 +47,6 @@ import { NgIf } from '@angular/common';
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<div class="my-4">
|
||||
<mat-divider></mat-divider>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-3">
|
||||
<a mat-stroked-button href="/oauth2/authorization/google" class="w-full">
|
||||
Sign in with Google
|
||||
</a>
|
||||
<a mat-stroked-button href="/oauth2/authorization/github" class="w-full">
|
||||
Sign in with GitHub
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<p class="text-center mt-6 text-sm text-gray-500">
|
||||
Don't have an account?
|
||||
<a routerLink="/register" class="text-indigo-600 font-medium hover:underline">Register</a>
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { AuthService } from '../../core/services/auth.service';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
|
||||
@Component({
|
||||
selector: 'app-oauth-callback',
|
||||
standalone: true,
|
||||
imports: [MatProgressSpinnerModule],
|
||||
template: `
|
||||
<div class="min-h-screen flex items-center justify-center bg-gray-50">
|
||||
<div class="text-center">
|
||||
<mat-spinner diameter="40" class="mx-auto mb-4"></mat-spinner>
|
||||
<p class="text-gray-500">Completing sign in...</p>
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
})
|
||||
export class OAuthCallbackComponent implements OnInit {
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private authService: AuthService,
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
const accessToken = this.route.snapshot.queryParamMap.get('accessToken');
|
||||
const refreshToken = this.route.snapshot.queryParamMap.get('refreshToken');
|
||||
|
||||
if (accessToken && refreshToken) {
|
||||
this.authService.setSessionFromOAuth(accessToken, refreshToken);
|
||||
this.router.navigate(['/dashboard']);
|
||||
} else {
|
||||
this.router.navigate(['/login']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,5 +10,4 @@ export interface UserInfo {
|
||||
email: string;
|
||||
name: string;
|
||||
avatarUrl: string;
|
||||
provider: 'LOCAL' | 'GOOGLE' | 'GITHUB' | 'OPENID';
|
||||
}
|
||||
|
||||
@@ -50,23 +50,6 @@ export class AuthService {
|
||||
return !!this.getAccessToken();
|
||||
}
|
||||
|
||||
setSessionFromOAuth(accessToken: string, refreshToken: string): void {
|
||||
localStorage.setItem(this.ACCESS_TOKEN_KEY, accessToken);
|
||||
localStorage.setItem(this.REFRESH_TOKEN_KEY, refreshToken);
|
||||
const payload = this.decodeToken(accessToken);
|
||||
if (payload) {
|
||||
const user: UserInfo = {
|
||||
id: payload.sub,
|
||||
email: payload.email,
|
||||
name: payload.name,
|
||||
avatarUrl: payload.avatarUrl || '',
|
||||
provider: payload.provider || 'LOCAL',
|
||||
};
|
||||
localStorage.setItem(this.USER_KEY, JSON.stringify(user));
|
||||
this.userSubject.next(user);
|
||||
}
|
||||
}
|
||||
|
||||
clearSessionForLogout(): void {
|
||||
this.clearSession();
|
||||
}
|
||||
@@ -90,12 +73,4 @@ export class AuthService {
|
||||
return data ? JSON.parse(data) : null;
|
||||
}
|
||||
|
||||
private decodeToken(token: string): any {
|
||||
try {
|
||||
const parts = token.split('.');
|
||||
return JSON.parse(atob(parts[1]));
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user