-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MNOE-497] [WIP] Move rails pages to SPA #236
Open
adamaziz15
wants to merge
18
commits into
maestrano:2.0
Choose a base branch
from
adamaziz15:feature/497-move-rails-pages
base: 2.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
77990cd
Move login page to SPA - WIP
adamaziz15 33505c2
Add signup route
adamaziz15 8e4fd92
Update styling and error handling
adamaziz15 1941c87
Signup page
adamaziz15 b932a78
Update error handling
adamaziz15 023e4a6
Password recovery page
rheasunshine 2424b8e
login ui-sref change
rheasunshine 9f79905
Confirmation lounge and resend confirmation action
adamaziz15 77b78d2
Add route for confirmation page and update styling
adamaziz15 ab761a8
[MNOE-544] Onboarding: fix locales
alexnoox a9e4d40
Password reset controller and password strength directive
rheasunshine bb502ed
Password reset CSS
rheasunshine aac66df
Error handling for password reset
rheasunshine c25c9d5
Update routing and begin work on confirmation pages
adamaziz15 5ef8f09
Update confirmation routing and controller
adamaziz15 33f6872
Confirmation pages ported over (confirmation, lounge, recovery)
adamaziz15 31742d0
Begin to port over unlock pages
adamaziz15 7641d70
Authorize page ported over and partial unlock page
adamaziz15 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
149 changes: 149 additions & 0 deletions
149
src/app/components/mno-password-strength/mno-password-strength.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
angular.module 'mnoEnterpriseAngular' | ||
.directive 'mnoPasswordStrength', (MnoErrorsHandler) -> | ||
require: "ngModel" | ||
restrict: 'A' | ||
scope: | ||
passwordScore: '=' #outject score | ||
|
||
link: (scope, element, attrs, ctrl) -> | ||
measureStrength = (p) -> | ||
matches = | ||
pos: {} | ||
neg: {} | ||
|
||
counts = | ||
pos: {} | ||
neg: | ||
seqLetter: 0 | ||
seqNumber: 0 | ||
seqSymbol: 0 | ||
|
||
tmp = undefined | ||
strength = 0 | ||
letters = "abcdefghijklmnopqrstuvwxyz" | ||
numbers = "01234567890" | ||
symbols = "\\!@#$%&/()=?¿" | ||
back = undefined | ||
forth = undefined | ||
|
||
if p | ||
# Benefits | ||
matches.pos.lower = p.match(/[a-z]/g) | ||
matches.pos.upper = p.match(/[A-Z]/g) | ||
matches.pos.numbers = p.match(/\d/g) | ||
matches.pos.symbols = p.match(/[$-/:-?{-~!^_`\[\]]/g) | ||
matches.pos.middleNumber = p.slice(1, -1).match(/\d/g) | ||
matches.pos.middleSymbol = p.slice(1, -1).match(/[$-/:-?{-~!^_`\[\]]/g) | ||
counts.pos.lower = (if matches.pos.lower then matches.pos.lower.length else 0) | ||
counts.pos.upper = (if matches.pos.upper then matches.pos.upper.length else 0) | ||
counts.pos.numbers = (if matches.pos.numbers then matches.pos.numbers.length else 0) | ||
counts.pos.symbols = (if matches.pos.symbols then matches.pos.symbols.length else 0) | ||
tmp = _.reduce(counts.pos, (memo, val) -> | ||
# if has count will add 1 | ||
memo + Math.min(1, val) | ||
, 0) | ||
counts.pos.numChars = p.length | ||
tmp += (if (counts.pos.numChars >= 8) then 1 else 0) | ||
counts.pos.requirements = (if (tmp >= 3) then tmp else 0) | ||
counts.pos.middleNumber = (if matches.pos.middleNumber then matches.pos.middleNumber.length else 0) | ||
counts.pos.middleSymbol = (if matches.pos.middleSymbol then matches.pos.middleSymbol.length else 0) | ||
|
||
# Deductions | ||
matches.neg.consecLower = p.match(/(?=([a-z]{2}))/g) | ||
matches.neg.consecUpper = p.match(/(?=([A-Z]{2}))/g) | ||
matches.neg.consecNumbers = p.match(/(?=(\d{2}))/g) | ||
matches.neg.onlyNumbers = p.match(/^[0-9]*$/g) | ||
matches.neg.onlyLetters = p.match(/^([a-z]|[A-Z])*$/g) | ||
counts.neg.consecLower = (if matches.neg.consecLower then matches.neg.consecLower.length else 0) | ||
counts.neg.consecUpper = (if matches.neg.consecUpper then matches.neg.consecUpper.length else 0) | ||
counts.neg.consecNumbers = (if matches.neg.consecNumbers then matches.neg.consecNumbers.length else 0) | ||
|
||
# sequential letters (back and forth) | ||
i = 0 | ||
while i < letters.length - 2 | ||
p2 = p.toLowerCase() | ||
forth = letters.substring(i, parseInt(i + 3)) | ||
back = _(forth).split("").reverse() | ||
counts.neg.seqLetter++ if p2.indexOf(forth) isnt -1 or p2.indexOf(back) isnt -1 | ||
i++ | ||
|
||
# sequential numbers (back and forth) | ||
i = 0 | ||
while i < numbers.length - 2 | ||
forth = numbers.substring(i, parseInt(i + 3)) | ||
back = _(forth).split("").reverse() | ||
counts.neg.seqNumber++ if p.indexOf(forth) isnt -1 or p.toLowerCase().indexOf(back) isnt -1 | ||
i++ | ||
|
||
# sequential symbols (back and forth) | ||
i = 0 | ||
while i < symbols.length - 2 | ||
forth = symbols.substring(i, parseInt(i + 3)) | ||
back = _(forth).split("").reverse() | ||
counts.neg.seqSymbol++ if p.indexOf(forth) isnt -1 or p.toLowerCase().indexOf(back) isnt -1 | ||
i++ | ||
|
||
# repeated chars | ||
counts.neg.repeated = _.chain(p.toLowerCase().split("")).countBy((val) -> | ||
val | ||
).reject((val) -> | ||
val is 1 | ||
).reduce((memo, val) -> | ||
memo + val | ||
, 0).value() | ||
|
||
# Calculations | ||
strength += counts.pos.numChars * 4 | ||
strength += (counts.pos.numChars - counts.pos.upper) * 2 if counts.pos.upper | ||
strength += (counts.pos.numChars - counts.pos.lower) * 2 if counts.pos.lower | ||
strength += counts.pos.numbers * 4 if counts.pos.upper or counts.pos.lower | ||
strength += counts.pos.symbols * 6 | ||
strength += (counts.pos.middleSymbol + counts.pos.middleNumber) * 2 | ||
strength += counts.pos.requirements * 2 | ||
strength -= counts.neg.consecLower * 2 | ||
strength -= counts.neg.consecUpper * 2 | ||
strength -= counts.neg.consecNumbers * 2 | ||
strength -= counts.neg.seqNumber * 3 | ||
strength -= counts.neg.seqLetter * 3 | ||
strength -= counts.neg.seqSymbol * 3 | ||
strength -= counts.pos.numChars if matches.neg.onlyNumbers | ||
strength -= counts.pos.numChars if matches.neg.onlyLetters | ||
strength -= (counts.neg.repeated / counts.pos.numChars) * 10 if counts.neg.repeated | ||
Math.max 0, Math.min(100, Math.round(strength)) | ||
|
||
getPwStrength = (s) -> | ||
switch Math.round(s / 20) | ||
when 0, 1 | ||
"weak" | ||
when 2,3 | ||
"good" | ||
when 4,5 | ||
"secure" | ||
|
||
getClass = (s) -> | ||
switch getPwStrength(s) | ||
when 'weak' | ||
"danger" | ||
when 'good' | ||
"warning" | ||
when 'secure' | ||
"success" | ||
|
||
isPwStrong = (s) -> | ||
switch getPwStrength(s) | ||
when 'weak' | ||
false | ||
else | ||
true | ||
|
||
scope.$watch (-> ctrl.$modelValue), -> | ||
scope.value = measureStrength(ctrl.$modelValue) | ||
scope.pwStrength = getPwStrength(scope.value) | ||
ctrl.$setValidity('password-strength', isPwStrong(scope.value)) | ||
if scope.passwordScore? | ||
scope.passwordScore.value = scope.pwStrength | ||
scope.passwordScore.class = getClass(scope.value) | ||
scope.passwordScore.showTip = (ctrl.$modelValue? && ctrl.$modelValue != '' && !isPwStrong(scope.value)) | ||
|
||
|
||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
angular.module 'mnoEnterpriseAngular' | ||
.factory 'MnoeAuthSvc', (Restangular, inflector) -> | ||
return Restangular.withConfig((RestangularProvider) -> | ||
RestangularProvider.setBaseUrl('/mnoe/auth') | ||
RestangularProvider.setDefaultHeaders({Accept: "application/json"}) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,13 +25,15 @@ angular.module 'mnoEnterpriseAngular' | |
) | ||
|
||
.config ($httpProvider) -> | ||
$httpProvider.interceptors.push ($q, $window) -> | ||
$httpProvider.interceptors.push ($q, $window, $injector, $log) -> | ||
{ | ||
responseError: (rejection) -> | ||
if rejection.status == 401 | ||
# Redirect to login page | ||
console.log "User is not connected!" | ||
$window.location.href = '/' | ||
toastr = $injector.get('toastr') | ||
|
||
toastr.error('User is not connected!') | ||
$log.error('User is not connected!') | ||
|
||
$q.reject rejection | ||
} | ||
|
@@ -84,3 +86,22 @@ angular.module 'mnoEnterpriseAngular' | |
# TODO: Activate in "developer mode" only (spams the console and makes the application lag) | ||
# $translateProvider.useMissingTranslationHandlerLog() | ||
) | ||
# Configure auth routes | ||
.config((AuthProvider, AuthInterceptProvider) -> | ||
AuthProvider.loginPath('/mnoe/auth/users/sign_in') | ||
AuthProvider.logoutPath('/mnoe/auth/users/sign_out') | ||
AuthProvider.registerPath('/mnoe/auth/users/') | ||
AuthProvider.sendResetPasswordInstructionsPath('/mnoe/auth/users/password') | ||
AuthProvider.resetPasswordPath('/mnoe/auth/users/password') | ||
AuthInterceptProvider.interceptAuth(true) | ||
) | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove empty lines |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should i18n this toastr