Skip to content

Commit

Permalink
Merge pull request #356 from appirio-tech/dev
Browse files Browse the repository at this point in the history
New Auth0 Flow and bug fixes
  • Loading branch information
sachin-maheshwari authored Aug 31, 2020
2 parents 70875b6 + 627eaab commit b3b5950
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ workflows:
context : org-global
filters:
branches:
only: [ dev, "new_ui_style"]
only: [ dev, "new_ui_style", 'feature/RS256-backward-compatibility']
- build-qa:
context : org-global
filters:
Expand Down
21 changes: 21 additions & 0 deletions app/scripts/directives/validate-confirm-password.directive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import angular from 'angular'

(function () {
'use strict'

angular.module('accounts.directives').directive('validConfirmPassword', validConfirmPassword)

function validConfirmPassword() {
return {
require: 'ngModel',
link: function (scope, element, attrs, ctrl) {
ctrl.$validators.validConfirmPassword = function (modelValue, viewValue) {
if (modelValue === ctrl.$$parentForm.password.$modelValue) {
return true
}
return false
}
}
}
}
})()
4 changes: 3 additions & 1 deletion app/views/directives/toggle-confirm-password.directive.jade
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
aria-describedby="tp-help-password",
aria-required="false",
class="input input-btn {{ vm.hasPasswordError() ? 'error' : ''}}"
required)
required,
valid-confirm-password
)

button.tc-btn.tc-btn-sm.show-password-btn(type="button", id="toggleInputTypeBtn", tabIndex="0", ng-click="vm.toggleTypeAttribute()")
img(src=logoViewPassword, alt="View Password")
4 changes: 2 additions & 2 deletions app/views/tc/register.jade
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@

p.form-error(ng-message="required" role="alert") Please enter an email address.

.validation-bar
.validation-bar(ng-class="{ 'error-bar': (vm.registerForm.password.$dirty && vm.registerForm.password.$invalid) }")
md-input-container.md-block
label(for="password-input") Password
toggle-password-with-tips(ng-if="!vm.isSocialRegistration && !vm.ssoForced && !vm.ssoUser")
Expand All @@ -121,7 +121,7 @@

p(ng-class="{ 'has-symbol-or-number': (vm.registerForm.password.$dirty && !vm.registerForm.password.$error.hasSymbolOrNumber) }") At least one number or symbol

.validation-bar.confirm-password
.validation-bar.confirm-password(ng-class="{ 'error-bar': (vm.registerForm.confirmPassword.$dirty && vm.registerForm.confirmPassword.$invalid) }")
md-input-container.md-block
label(for="confirm-password-input") Confirm password
toggle-confirm-password(ng-if="!vm.isSocialRegistration && !vm.ssoForced && !vm.ssoUser")
Expand Down
19 changes: 17 additions & 2 deletions core/token.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { V3_JWT, AUTH0_REFRESH, AUTH0_JWT, V2_JWT, V2_SSO, ZENDESK_JWT, DOMAIN } from './constants.js'
import fromPairs from 'lodash/fromPairs'
import _ from 'lodash'

export function clearTokens() {
removeToken(V3_JWT)
Expand Down Expand Up @@ -34,8 +35,22 @@ export function decodeToken(token) {
if (!decoded) {
throw new Error('Cannot decode the token')
}

return JSON.parse(decoded)

// covert base64 token in JSON object
let t = JSON.parse(decoded)

// tweaking for custom claim for RS256 id-token
t.userId = _.parseInt(_.find(t, (value, key) => {
return (key.indexOf('userId') !== -1)
}))
t.handle = _.find(t, (value, key) => {
return (key.indexOf('handle') !== -1)
})
t.roles = _.find(t, (value, key) => {
return (key.indexOf('roles') !== -1)
})

return t
}

export function isTokenExpired(token, offsetSeconds = 0) {
Expand Down

0 comments on commit b3b5950

Please sign in to comment.