All files / platform/core/src/services/UserAuthenticationService UserAuthenticationService.ts

58.82% Statements 20/34
62.5% Branches 5/8
29.41% Functions 5/17
56.25% Lines 18/32

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93    34x             34x                             34x 34x                                   1698x                                               68x 68x   68x 68x   68x 68x   68x     68x     68x 68x   68x 68x     34x      
import { PubSubService } from '../_shared/pubSubServiceInterface';
 
class UserAuthenticationService extends PubSubService {
  public static readonly EVENTS = {};
 
  public static REGISTRATION = {
    name: 'userAuthenticationService',
    altName: 'UserAuthenticationService',
    create: ({ configuration = {} }) => {
      return new UserAuthenticationService();
    },
  };
 
  serviceImplementation = {
    _getState: () => console.warn('getState() NOT IMPLEMENTED'),
    _setUser: () => console.warn('_setUser() NOT IMPLEMENTED'),
    _getUser: () => console.warn('_getUser() NOT IMPLEMENTED'),
    _getAuthorizationHeader: () => {}, // TODO: Implement this method
    _handleUnauthenticated: () => console.warn('_handleUnauthenticated() NOT IMPLEMENTED'),
    _reset: () => console.warn('reset() NOT IMPLEMENTED'),
    _set: () => console.warn('set() NOT IMPLEMENTED'),
  };
 
  constructor() {
    super(UserAuthenticationService.EVENTS);
    this.serviceImplementation = {
      ...this.serviceImplementation,
    };
  }
 
  public getState() {
    return this.serviceImplementation._getState();
  }
 
  public setUser(user) {
    return this.serviceImplementation._setUser(user);
  }
 
  public getUser() {
    return this.serviceImplementation._getUser();
  }
 
  public getAuthorizationHeader() {
    return this.serviceImplementation._getAuthorizationHeader();
  }
 
  public handleUnauthenticated() {
    return this.serviceImplementation._handleUnauthenticated();
  }
 
  public reset() {
    return this.serviceImplementation._reset();
  }
 
  public set(state) {
    return this.serviceImplementation._set(state);
  }
 
  public setServiceImplementation({
    getState: getStateImplementation,
    setUser: setUserImplementation,
    getUser: getUserImplementation,
    getAuthorizationHeader: getAuthorizationHeaderImplementation,
    handleUnauthenticated: handleUnauthenticatedImplementation,
    reset: resetImplementation,
    set: setImplementation,
  }) {
    if (getStateImplementation) {
      this.serviceImplementation._getState = getStateImplementation;
    }
    if (setUserImplementation) {
      this.serviceImplementation._setUser = setUserImplementation;
    }
    if (getUserImplementation) {
      this.serviceImplementation._getUser = getUserImplementation;
    }
    Iif (getAuthorizationHeaderImplementation) {
      this.serviceImplementation._getAuthorizationHeader = getAuthorizationHeaderImplementation;
    }
    Iif (handleUnauthenticatedImplementation) {
      this.serviceImplementation._handleUnauthenticated = handleUnauthenticatedImplementation;
    }
    if (resetImplementation) {
      this.serviceImplementation._reset = resetImplementation;
    }
    if (setImplementation) {
      this.serviceImplementation._set = setImplementation;
    }
  }
}
 
export default UserAuthenticationService;