Advertisement
Guest User

Untitled

a guest
Jul 17th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { Injectable }               from '@angular/core';
  2. import { Observable }               from 'rxjs/Observable';
  3. import { UserRegistrationResponse } from '../interfaces/responses/user-registration-response';
  4. import { UserLoginResponse }        from '../interfaces/responses/user-login-response';
  5. import {HttpClient}                 from '@angular/common/http';
  6. import {ConstantsProviderService}   from './constants-provider.service';
  7.  
  8. @Injectable()
  9. export class UserService {
  10.  
  11.   constructor(private httpClient:HttpClient,private constantProviderService:ConstantsProviderService) {
  12.   }
  13.  
  14.   public loginUser(email:string,password:string):Observable<UserLoginResponse>{
  15.     let postBody = {
  16.       email:email,
  17.       password:password
  18.     };
  19.     let postUrl = this.constantProviderService.UserLoginPostUrl;
  20.     let userLogin:Observable<UserLoginResponse> = this.httpClient.post<UserLoginResponse>(postUrl,postBody);
  21.    
  22.     return userLogin;
  23.   }
  24.  
  25.   public registerUser(email:string,first_name:string,last_name:string,mobile:string,password:string):Observable<UserRegistrationResponse> {
  26.     let postBody = {
  27.       email:email,
  28.       first_name:first_name,
  29.       last_name:last_name,
  30.       mobile:mobile,
  31.       password:password
  32.     };
  33.     let postUrl = this.constantProviderService.UserRegistrationPostUrl;
  34.     let userRegistration:Observable<UserRegistrationResponse> = this.httpClient.post<UserRegistrationResponse>(postUrl,postBody);
  35.     return   userRegistration;
  36.   }
  37.  
  38. }
  39.  
  40. export enum UserRole {employee,user}
  41.  
  42. export interface AuthUser{
  43.   token:string;
  44.   role:UserRole;
  45.   first_name:string;
  46.   last_name:string;
  47.   email:string;
  48.   token_creation_time:number;
  49.   token_life:number;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement