Example #1
0
 getLimit()   //sends list of registration forms to panelist
 {
   console.log(this.sstorage.retrieve('username'));
   return this.http.get('assets/data/limit.json')
  // return this.http.get('panelist/'+this.userName)          //getting UserType
   .flatMap((data) =>data.json());
 }
Example #2
0
 storeAuthenticationToken(jwt, rememberMe) {
     if (rememberMe) {
         this.$localStorage.store('authenticationToken', jwt);
     } else {
         this.$sessionStorage.store('authenticationToken', jwt);
     }
 }
Example #3
0
 public getUser(): User {
     if (typeof this._user === 'undefined' || this._user === null) {
         const userFromSessionStorage: User = this.sessionStorage.retrieve(
             'user'
         );
         if (
             typeof userFromSessionStorage === 'undefined' ||
             userFromSessionStorage === null
         ) {
             this.router.navigate(['logout']);
         } else {
             this._user = userFromSessionStorage;
             return this._user;
         }
     } else {
         // check if user is still valid
         if (moment(this._user.exp * 1000).isBefore(moment(Date.now()))) {
             this.router.navigate(['logout']).then(() => {
                 setTimeout(() => {});
             });
             return undefined;
         }
         return this._user;
     }
 }
 constructor(
     private _script: ScriptLoaderService,
     private sessionStorage: SessionStorageService,
     private principal: Principal,
     private publicService: PublicService) {
     this.ctx = publicService.getServiceCtx('sys_module')
     this.nodeId = sessionStorage.retrieve("tree_module_select_node_id"), this.nodeId = (this.nodeId) ? this.nodeId : 1
 }
    requestIntercept(options?: RequestOptionsArgs): RequestOptionsArgs {
        if (!options || !options.url || (/^http/.test(options.url) && !(SERVER_API_URL && options.url.startsWith(SERVER_API_URL)))) {
            return options;
        }

        const token = this.localStorage.retrieve('authenticationToken') || this.sessionStorage.retrieve('authenticationToken');
        if (!!token) {
            options.headers.append('Authorization', 'Bearer ' + token);
        }
        return options;
    }
 storeDestinationState(destinationState, destinationStateParams, fromState) {
   const destinationInfo = {
     destination: {
       name: destinationState.name,
       data: destinationState.data
     },
     params: destinationStateParams,
     from: {
       name: fromState.name
     }
   };
   this.$sessionStorage.store('destinationState', destinationInfo);
 }
 storeDestinationState(destinationState, destinationStateParams, fromState) {
     const destinationInfo = {
         'destination': {
             'name': destinationState.name,
             'data': destinationState.data,
         },
         'params': destinationStateParams,
         'from': {
             'name': fromState.name,
         }
     }
     this.$sessionStorage.store('destinationState', destinationInfo)
 }
    intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
        if (!request || !request.url || (/^http/.test(request.url) && !(SERVER_API_URL && request.url.startsWith(SERVER_API_URL)))) {
            return next.handle(request);
        }

        const token = this.localStorage.retrieve('authenticationToken') || this.sessionStorage.retrieve('authenticationToken');
        if (!!token) {
            request = request.clone({
                setHeaders: {
                    Authorization: 'Bearer ' + token
                }
            });
        }
        return next.handle(request);
    }
 getPreviousState() {
   return this.$sessionStorage.retrieve('previousState');
 }
 getUrl() {
   return this.$sessionStorage.retrieve('previousUrl');
 }