{"size": 1110, "ext": "js", "max_stars_repo_path": "client/src/api/sso/mock.auth.service.js", "max_stars_repo_name": "microsoft/Odyss-e-de-Teams", "max_stars_repo_stars_event_min_datetime": "2022-02-28T10:26:18.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-28T11:37:06.000Z", "max_issues_repo_path": "client/src/api/sso/mock.auth.service.js", "max_issues_repo_name": "microsoft/Odyss-e-de-Teams", "max_issues_repo_issues_event_min_datetime": "2022-02-28T03:38:05.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T12:55:56.000Z", "max_forks_repo_path": "client/src/api/sso/mock.auth.service.js", "max_forks_repo_name": "microsoft/Odyss-e-de-Teams", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": 4, "max_forks_count": null, "avg_line_length": 24.1304347826, "max_line_length": 67, "alphanum_fraction": 0.5882882883}
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// A mock authentication service used for testing
class MockAuthService {
  isCallback = () => {
    return false;
  };

  login = () => {
    let mockUser = localStorage.getItem("mock.user");
    if (!mockUser) {
      mockUser = {
        name: "Mock User",
        objectId: "mock.user.id"
      };
      localStorage.setItem("mock.user", JSON.stringify(mockUser));
    }

    return Promise.resolve(mockUser);
  };

  logout = () => {
    localStorage.removeItem("mock.user");
  };

  getUser = () => {
    const mockUser = localStorage.getItem("mock.user");
    if (mockUser) {
      return Promise.resolve(JSON.parse(mockUser));
    } else {
      return Promise.reject("User information is not available");
    }
  };

  getToken = () => {
    const mockUser = localStorage.getItem("mock.user");
    if (mockUser) {
      return Promise.resolve("mock.token");
    } else {
      return Promise.reject("User information is not available");
    }
  };
}

export default MockAuthService;
