import { HttpResponse } from '@angular/common/http'; import { Observable } from 'rxjs/Rx'; import { NbAuthResult } from '../services/auth.service'; import { deepExtend, getDeepFromObject } from '../helpers'; export abstract class NbAbstractAuthProvider { protected defaultConfig: any = {}; protected config: any = {}; setConfig(config: any): void { this.config = deepExtend({}, this.defaultConfig, config); } getConfigValue(key: string): any { return getDeepFromObject(this.config, key, null); } abstract authenticate(data?: any): Observable; abstract register(data?: any): Observable; abstract requestPassword(data?: any): Observable; abstract resetPassword(data?: any): Observable; abstract logout(): Observable; protected createFailResponse(data?: any): HttpResponse { return new HttpResponse({ body: {}, status: 401 }); } protected createSuccessResponse(data?: any): HttpResponse { return new HttpResponse({ body: {}, status: 200 }); } protected getJsonSafe(res: HttpResponse): any { return res.body; } }