Skip to content
This repository was archived by the owner on Jan 14, 2020. It is now read-only.

fix: Promise -> $q #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/login.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { decodeBase64Url } from './utils'

class LoginService {
constructor (
$q,
$http,
$window,
$rootRouter,
Expand All @@ -11,6 +12,7 @@ class LoginService {
mainService,
userSessionService
) {
this.$q = $q
this.$http = $http
this.$window = $window
this.$rootRouter = $rootRouter
Expand Down Expand Up @@ -68,16 +70,16 @@ class LoginService {
canActivate () {
const isValidSession = (local, remote) => {
if (!remote.ok) {
return Promise.reject('session invalid')
return this.$q.reject('session invalid')
}
if (!(remote.userCtx && remote.userCtx.name)) {
return Promise.reject('missing user context in remote session')
return this.$q.reject('missing user context in remote session')
}
if (!local.userName) {
return Promise.reject('missing user name in local session')
return this.$q.reject('missing user name in local session')
}
if (remote.userCtx.name.toLowerCase() !== local.userName.toLowerCase()) {
return Promise.reject(`session mismatch for user ${local.userName}`)
return this.$q.reject(`session mismatch for user ${local.userName}`)
}
}

Expand Down Expand Up @@ -128,6 +130,7 @@ class LoginService {
}

LoginService.$inject = [
'$q',
'$http',
'$window',
'$rootRouter',
Expand Down