Ag Grid anpassungen
This commit is contained in:
@@ -5,6 +5,7 @@ import { BehaviorSubject, Observable, tap, of, catchError } from 'rxjs';
|
||||
import { IUser } from '../../model/interface/user.interface';
|
||||
import { environment } from '../../../environments/environment';
|
||||
import { HotToastService } from '@ngxpert/hot-toast';
|
||||
import { ApiService } from '../../shared/api.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -16,6 +17,7 @@ export class AuthService {
|
||||
private http: HttpClient = inject(HttpClient);
|
||||
private router: Router = inject(Router);
|
||||
private toast: HotToastService = inject(HotToastService);
|
||||
private api: ApiService = inject(ApiService);
|
||||
|
||||
private _user: IUser | null = null;
|
||||
|
||||
@@ -35,21 +37,27 @@ export class AuthService {
|
||||
return this.user != null && this.user.role == 'admin';
|
||||
}
|
||||
|
||||
getMe() {
|
||||
async getMe() {
|
||||
if (!this.getAccessToken()) {
|
||||
return false;
|
||||
}
|
||||
return new Promise(resolve => {
|
||||
this.http.get<IUser>('/api/auth/me').subscribe({
|
||||
next: user => {
|
||||
this._user = user;
|
||||
resolve(true)
|
||||
},
|
||||
error: () => {
|
||||
resolve(false)
|
||||
}
|
||||
})
|
||||
})
|
||||
const user = await this.api.getMe();
|
||||
if (user) {
|
||||
this._user = user;
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
return Promise.resolve(false)
|
||||
// return new Promise(resolve => {
|
||||
// this.http.get<IUser>('/api/auth/me').subscribe({
|
||||
// next: user => {
|
||||
// this._user = user;
|
||||
// resolve(true)
|
||||
// },
|
||||
// error: () => {
|
||||
// resolve(false)
|
||||
// }
|
||||
// })
|
||||
// })
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user