@app/_models#User TypeScript Examples

The following examples show how to use @app/_models#User. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: account.service.ts    From angular-10-registration-login-example with MIT License 6 votes vote down vote up
login(username, password) {
        return this.http.post<User>(`${environment.apiUrl}/users/authenticate`, { username, password })
            .pipe(map(user => {
                // store user details and jwt token in local storage to keep user logged in between page refreshes
                localStorage.setItem('user', JSON.stringify(user));
                this.userSubject.next(user);
                return user;
            }));
    }
Example #2
Source File: home.component.ts    From angular-10-role-based-authorization-example with MIT License 5 votes vote down vote up
userFromApi: User;
Example #3
Source File: home.component.ts    From angular-10-registration-login-example with MIT License 5 votes vote down vote up
user: User;
Example #4
Source File: authentication.service.ts    From angular-10-role-based-authorization-example with MIT License 5 votes vote down vote up
constructor(
        private router: Router,
        private http: HttpClient
    ) {
        this.userSubject = new BehaviorSubject<User>(JSON.parse(localStorage.getItem('user')));
        this.user = this.userSubject.asObservable();
    }
Example #5
Source File: authentication.service.ts    From angular-10-role-based-authorization-example with MIT License 5 votes vote down vote up
private userSubject: BehaviorSubject<User>;
Example #6
Source File: authentication.service.ts    From angular-10-role-based-authorization-example with MIT License 5 votes vote down vote up
public user: Observable<User>;
Example #7
Source File: user.service.ts    From angular-10-role-based-authorization-example with MIT License 5 votes vote down vote up
getAll() {
        return this.http.get<User[]>(`${environment.apiUrl}/users`);
    }
Example #8
Source File: user.service.ts    From angular-10-role-based-authorization-example with MIT License 5 votes vote down vote up
getById(id: number) {
        return this.http.get<User>(`${environment.apiUrl}/users/${id}`);
    }
Example #9
Source File: admin.component.ts    From angular-10-role-based-authorization-example with MIT License 5 votes vote down vote up
users: User[] = [];
Example #10
Source File: home.component.ts    From angular-10-role-based-authorization-example with MIT License 5 votes vote down vote up
user: User;
Example #11
Source File: account.service.ts    From angular-10-registration-login-example with MIT License 5 votes vote down vote up
public user: Observable<User>;
Example #12
Source File: user.service.ts    From angular-11-crud-example with MIT License 5 votes vote down vote up
getAll() {
        return this.http.get<User[]>(baseUrl);
    }
Example #13
Source File: user.service.ts    From angular-11-crud-example with MIT License 5 votes vote down vote up
getById(id: string) {
        return this.http.get<User>(`${baseUrl}/${id}`);
    }
Example #14
Source File: list.component.ts    From angular-11-crud-example with MIT License 5 votes vote down vote up
users!: User[];
Example #15
Source File: fake-backend.ts    From angular-9-jwt-authentication-example with MIT License 5 votes vote down vote up
users: User[] = [{ id: 1, username: 'test', password: 'test', firstName: 'Test', lastName: 'User' }]
Example #16
Source File: home.component.ts    From angular-9-jwt-authentication-example with MIT License 5 votes vote down vote up
users: User[];
Example #17
Source File: fake-backend.ts    From angular-9-role-based-authorization-example with MIT License 5 votes vote down vote up
users: User[] = [
    { id: 1, username: 'admin', password: 'admin', firstName: 'Admin', lastName: 'User', role: Role.Admin },
    { id: 2, username: 'user', password: 'user', firstName: 'Normal', lastName: 'User', role: Role.User }
]
Example #18
Source File: user.service.ts    From angular-master-details-crud-example with MIT License 5 votes vote down vote up
getAll() {
        return this.http.get<User[]>(baseUrl);
    }
Example #19
Source File: user.service.ts    From angular-master-details-crud-example with MIT License 5 votes vote down vote up
getById(id: string) {
        return this.http.get<User>(`${baseUrl}/${id}`);
    }
Example #20
Source File: authentication.service.ts    From angular-10-jwt-refresh-tokens with MIT License 5 votes vote down vote up
constructor(
        private router: Router,
        private http: HttpClient
    ) {
        this.userSubject = new BehaviorSubject<User>(null);
        this.user = this.userSubject.asObservable();
    }
Example #21
Source File: authentication.service.ts    From angular-10-basic-authentication-example with MIT License 5 votes vote down vote up
constructor(
        private router: Router,
        private http: HttpClient
    ) {
        this.userSubject = new BehaviorSubject<User>(JSON.parse(localStorage.getItem('user')));
        this.user = this.userSubject.asObservable();
    }
Example #22
Source File: authentication.service.ts    From angular-10-basic-authentication-example with MIT License 5 votes vote down vote up
private userSubject: BehaviorSubject<User>;
Example #23
Source File: authentication.service.ts    From angular-10-basic-authentication-example with MIT License 5 votes vote down vote up
public user: Observable<User>;
Example #24
Source File: user.service.ts    From angular-10-basic-authentication-example with MIT License 5 votes vote down vote up
getAll() {
        return this.http.get<User[]>(`${environment.apiUrl}/users`);
    }
Example #25
Source File: home.component.ts    From angular-10-basic-authentication-example with MIT License 5 votes vote down vote up
users: User[];
Example #26
Source File: authentication.service.ts    From angular-10-jwt-authentication-example with MIT License 5 votes vote down vote up
constructor(private http: HttpClient) {
        this.currentUserSubject = new BehaviorSubject<User>(JSON.parse(localStorage.getItem('currentUser')));
        this.currentUser = this.currentUserSubject.asObservable();
    }
Example #27
Source File: authentication.service.ts    From angular-10-jwt-authentication-example with MIT License 5 votes vote down vote up
private currentUserSubject: BehaviorSubject<User>;
Example #28
Source File: authentication.service.ts    From angular-10-jwt-authentication-example with MIT License 5 votes vote down vote up
public currentUser: Observable<User>;
Example #29
Source File: fake-backend.ts    From angular-10-basic-authentication-example with MIT License 5 votes vote down vote up
users: User[] = [{ id: 1, username: 'test', password: 'test', firstName: 'Test', lastName: 'User' }]