WIP reorganization

This commit is contained in:
Erik Ziegler committed 2018-12-12 09:10:39 +01:00
1 parent 6706dfe634
commit 054e37dfb7
266 files changed
+98 -620

No files matched your search

+13
View File
@@ -0,0 +1,13 @@
language: node_js
node_js:
- "0.10"
#sudo: required
sudo: required
env:
global:
- METEOR_ENV=development
before_install:
- "curl -L http://git.io/ejPSng | /bin/sh"
@@ -0,0 +1,34 @@
## Contributing
**Submit your Pull Request on a Feature Branch**
- To ensure your pull-request has the greatest chance of getting merged in, please submit it on a feature branch rather than directly to master.
- Please see [A successful Git branching model](http://nvie.com/posts/a-successful-git-branching-model/) for more details.
**Quality Assurance**
- Pull Requests will be generally accepted as long as the QA tests pass on [Circle CI](https://circleci.com/gh/clinical-meteor/clinical-active-entry).
- Begin a Pull Request by logging an Issue for discussion.
- Next, clone the package into a project for local development.
- Use ``git checkout -b newfeature`` to create a new branch.
- Run the package verification tests to ensure that the test runner works.
- Add an it() clause at the bottom of the [activeEntryTests.js](https://github.com/clinical-meteor/clinical-active-entry/blob/master/tests/gagarin/activeEntryTests.js) file for each new feature you wish to implement.
- Sketch out a test script for a feature.
- Run the verification tests, and confirm that the new test fails.
- Update the package with the new feature until the new test passes.
- Push the package to the repo on GitHub.
- Submit a pull-request.
- If the PR passes tests on Circle CI, we'll merge it in!
**Reference Implementation**
- Please see the [ChecklistManifest](http://checklist-manifesto.meteor.com/) and it's [source code](https://github.com/clinical-meteor/checklist-manifesto) for a reference implementation of the ActiveEntry package. It's being built as a workqueue, and is being designed to be FDA, HIPAA, and HL7 FHIR compliant.
**Feature Toggling**
- In general, it's a best practice to implement features that can be enabled/disabled. Some people will want a feature; others will not. The best way to toggle features is adding them to a config file, which is what the [ActiveEntry](https://github.com/clinical-meteor/clinical-active-entry/blob/master/lib/ActiveEntry.js) object is for.
- It's recommended that fields be added to the ActiveEntryConfig object that can be used to enabled/disable the feature you are implementing.
- The ActiveEntryConfig object can be roughly considered as analogous to the ``props`` field that is passed into React templates.
**Theming and Styling**
- Different apps require different presentation/style layers, so Clinical Meteor has implemented a [Theme](https://github.com/clinical-meteor/clinical-theming/blob/master/objects/Theme.js) object which manages theming. Generally speaking, we're trying to avoid the inclusion of third-party component libraries, UI widgets, and CSS frameworks, and keeping the Clinical Meteor packages as close to the default HTML that Blaze produces as possible (while using line styles for animation effects).
- Generally speaking, Bootstrap HTML structure in acceptable in designing pages, but avoid including global CSS files, and keep any CSS locally scoped using LESS nested classes. This approach allows people to add the Bootstrap library if they want it, prevents cascading leaks, and allows more fine-grained control over CSS to implement animation effects.
- Pull requests that include visual integration with other projects are acceptable, but please submit an issue for discussion before submitting PRs with wholesale changes that include Jade, Material UI, React, etc.
- The ActiveEntry pages are designed to be used in an IronRouter Layout template. As such, no height/width constraints are provided. It's assumed that the layout template will take care of such things. But basic padding/margin is provided.
+130
View File
@@ -0,0 +1,130 @@
## clinical:active-entry
This package provides the SignIn, SignUp, and ForgotPassword pages.
[![Circle CI](https://circleci.com/gh/clinical-meteor/active-entry/tree/master.svg?style=svg)](https://circleci.com/gh/clinical-meteor/active-entry/tree/master)
===============================
#### Installation
````
meteor add clinical:active-entry
````
===============================
#### Entry Flowchart
The following diagram represents the entry workflow that is being implemented in this package. This package is under active development, and is about half completed. Pull requests which help implement the following workflow will be fast-tracked and accepted into the package.
![entry-workflow](https://raw.githubusercontent.com/clinical-meteor/active-entry/master/docs/Entry%20Workflow.png)
===============================
#### Routing API
````
/entrySignIn
/entrySignUp
/forgotPassword
````
===============================
#### Component API
````
{{> entrySignIn }}
{{> entrySignUp }}
{{> forgotPassword }}
````
===============================
#### ActiveEntry Configuration
````js
if(Meteor.isClient){
ActiveEntry.configure({
logo: {
url: "/mini-circles.png",
displayed: true
},
signIn: {
displayFullName: true,
destination: "/table/users"
},
signUp: {
destination: "/table/users"
},
themeColors: {
primary: ""
}
});
}
if(Meteor.isServer){
Accounts.emailTemplates.siteName = "AwesomeSite";
Accounts.emailTemplates.from = "AwesomeSite Admin <accounts@example.com>";
Accounts.emailTemplates.enrollAccount.subject = function (user) {
return "Welcome to Awesome Town, " + user.profile.name;
};
Accounts.emailTemplates.enrollAccount.text = function (user, url) {
return "You have been selected to participate in building a better future!"
+ " To activate your account, simply click the link below:\n\n"
+ url;
};
Meteor.startup(function(){
process.env.MAIL_URL = 'smtp://sandboxid.mailgun.org:mypassword@smtp.mailgun.org:587';
})
}
````
Alternatively, you may want to set the ``MAIL_URL`` via an external environment variable, particularly if you're using a SaaS hosting provider.
````sh
MAIL_URL = 'smtp://sandboxid.mailgun.org:mypassword@smtp.mailgun.org:587' meteor
````
===============================
#### Local Development
Simply clone the repository into your ``/packages`` directory. You can also specify the packages you want to develop locally in your ``.git-packages.json`` file, and use starrynight to fetch them.
````bash
# clone a single package into your application
git clone http://github.com/clinical-meteor/clinical-active-entry packages/active-entry
# fetch all the packages listed in git-packages.json
starrynight fetch
````
===============================
#### Quality Assurance Testing
There are two types of quality assurance tests you can run: verification and validation tests. Verification tests are similar to unit or integration tests; and can run either at the application or package level. Validation tests are application-wide, but often require commands exposed in packages. So you'll need to run the ``autoconfig`` command to scan the filesystem for validation commands. See [http://starrynight.meteor.com/](http://starrynight.meteor.com/) for more details.
````bash
# install the testing utility
npm install -g starrynight
# verification testing (a.k.a. package-level unit/integration testing)
starrynight run-tests --type package-verification
#to run validation tests, you'll need an ``.initializeUsers()`` function
meteor add clinical:accounts-housemd
#validation testing (a.k.a. application acceptance/end-to-end testing)
starrynight autoscan
starrynight run-tests --type validation
````
===============================
#### Contributing
See our [notes on contributing](https://github.com/clinical-meteor/clinical-active-entry/blob/master/Contributing.md).
===============================
#### Licensing
![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)
+84
View File
@@ -0,0 +1,84 @@
## Customize the test machine
machine:
node:
version: 0.10.33
# Timezone
timezone:
America/Los_Angeles # Set the timezone
# Add some environment variables
environment:
CIRCLE_ENV: test
CXX: g++-4.8
DISPLAY: :99.0
NPM_PREFIX: /home/ubuntu/nvm/v0.10.33
## Customize checkout
checkout:
post:
#- git submodule sync
#- git submodule update --init --recursive # use submodules
#general:
# build_dir: helloworld
## Customize dependencies
dependencies:
cache_directories:
- ~/.meteor # relative to the user's home directory
- ~/nvm/v0.10.33/lib/node_modules/starrynight
- ~/nvm/v0.10.33/bin/starrynight
pre:
# Install Starrynight unless it is cached
- if [ ! -e ~/nvm/v0.10.33/bin/starrynight ]; then npm install -g starrynight; else echo "Starrynight seems to be cached"; fi;
# Install Meteor
- mkdir -p ${HOME}/.meteor
# If Meteor is already cached, do not need to build it again.
- if [ ! -e ${HOME}/.meteor/meteor ]; then curl https://install.meteor.com | /bin/sh; else echo "Meteor seems to be cached"; fi;
# Link the meteor executable into /usr/bin
- sudo ln -s $HOME/.meteor/meteor /usr/bin/meteor
# Check if the helloworld directory already exists, if it doesn't, create the helloworld app
# The following doesn't work, because it should be checking ${HOME}/active-entry/helloworld
# - if [ ! -e ${HOME}/helloworld ]; then meteor create --release METEOR@1.1.0.3 helloworld; else echo "helloworld app seems to be cached"; fi;
override:
- cd ${HOME} && meteor create --release METEOR@1.1.0.3 helloworld
- cd ${HOME}/helloworld
- cd ${HOME}/helloworld && ls -la
- cd ${HOME}/helloworld && rm helloworld.*
- cd ${HOME}/helloworld && mkdir packages && mkdir packages/active-entry
- cp -R * ${HOME}/helloworld/packages/active-entry
- cd ${HOME}/helloworld && meteor add anti:gagarin@0.4.11 accounts-base accounts-password session meteor-platform clinical:user-model clinical:active-entry
- cd ${HOME}/helloworld && starrynight autoconfig
- cd ${HOME}/helloworld && meteor list
- cat tests/gagarin/activeEntryTests.js
- ls -la
- cd ~ && ls -la
- cd ${HOME} && pwd
- cd ${HOME} && ls -la
- cd ${HOME}/helloworld && ls -la
## Customize test commands
test:
pre:
- cd helloworld && meteor:
background: true
- sleep 30
override:
- cd ${HOME}/helloworld && starrynight run-tests --type package-verification
## Customize deployment commands
#deployment:
# production:
# branch: master
# commands:
# - printf "<Meteor username>\n<Meteor password>\n" | meteor deploy circlecivelocity.meteor.com
## Custom notifications
#notify:
#webhooks:
# A list of hashes representing hooks. Only the url field is supported.
#- url: https://someurl.com/hooks/circle
@@ -0,0 +1,48 @@
<template name="changePassword">
<div id="changePassword" class="page entryPage" style="{{getOpacityWithCorner}}">
<div class="content-scrollable">
<div class="wrapper-auth">
<div class="entryLogo" style="background-image: url('{{getLogoUrl}}')"></div>
<h1 id="changePasswordPageTitle" class="title-auth">Change Password</h1>
<div id="changePasswordPageMessage" class="subtitle-auth" style="{{getChangePasswordMessageColor}}">{{getChangePasswordMessage}}</div>
<form>
{{#if changePasswordErrorMessages}}
<div id="errorMessages" class="list-errors">
{{#each changePasswordErrorMessages}}
<div class="alert alert-danger list-item">{{this}}</div>
{{/each}}
</div>
{{/if}}
<div class="input-symbol">
<input id="changePasswordPageOldPasswordInput" type="password" name="oldPassword" placeholder="Old Password" style="{{getPasswordStyling}}" />
<span class="fa fa-lock" title="Password"></span>
</div>
<br>
<br>
<div class="input-symbol">
<input id="changePasswordPagePasswordInput" type="password" name="password" placeholder="Password" style="{{getPasswordStyling}}" />
<span class="fa fa-lock" title="Password"></span>
</div>
<br>
<br>
<div class="input-symbol">
<input id="changePasswordPagePasswordConfirmInput" type="password" name="confirm" placeholder="Confirm Password" style="{{getConfirmPasswordStyling}}" />
<span class="fa fa-lock" title="Confirm Password"></span>
</div>
<br><br>
<button id="changePasswordButton" type="submit" class="btn-gray btn-main btn-large" style="{{getButtonColor}}">Change Password</button>
<br><br>
</form>
</div>
</div>
</div>
</template>
@@ -0,0 +1,100 @@
//==========================================
Router.route('/changePassword', {
name: "changePassword",
template: "changePassword"
});
Template.changePassword.helpers({
getChangePasswordMessageColor: function (){
if (ActiveEntry.errorMessages.get('changePasswordError')) {
return "color: #a94442; background-color: #f2dede; border-color: #ebccd1;"
} else {
return "color: black;"
}
},
getChangePasswordMessage: function (){
if (ActiveEntry.errorMessages.get('changePasswordError')) {
return ActiveEntry.errorMessages.get('changePasswordError');
} else {
return Session.get('defaultSignInMessage');
}
},
getPasswordStyling: function () {
if (ActiveEntry.errorMessages.equals('password', "Password is required")) {
return "border: 1px solid #a94442";
} else if (ActiveEntry.errorMessages.equals('password', "Password is weak")) {
return "border: 1px solid #f2dede";
} else if (ActiveEntry.errorMessages.equals('password', "Password present")) {
return "border: 1px solid green";
} else {
return "border: 1px solid gray";
}
},
getConfirmPasswordStyling: function () {
if (ActiveEntry.errorMessages.equals('confirm', "Password is required")) {
return "border: 1px solid #a94442";
} else if (ActiveEntry.errorMessages.equals('confirm', "Passwords do not match")) {
return "border: 1px solid #a94442";
} else if (ActiveEntry.errorMessages.equals('confirm', "Password is weak")) {
return "border: 1px solid #f2dede";
} else if (ActiveEntry.errorMessages.equals('confirm', "Passwords match")) {
return "border: 1px solid green";
} else {
return "border: 1px solid gray";
}
},
changePasswordErrorMessages: function() {
var allErrorMessages = Object.keys(ActiveEntry.errorMessages.all()).filter(function(key) {
return (key === "password" || key === "confirm") && ActiveEntry.errorMessages.get(key);
});
if (allErrorMessages.length > 0) {
var errorMessage = ActiveEntry.errorMessages.get(allErrorMessages[0]);
if (errorMessage) {
return [errorMessage];
}
}
return;
}
});
Template.changePassword.events({
'change, keyup #changePasswordPagePasswordInput': function (event, template) {
var password = $('[name="password"]').val();
var confirmPassword = $('[name="confirm"]').val();
ActiveEntry.verifyPassword(password);
ActiveEntry.errorMessages.set('changePasswordError', null);
},
'change, keyup #changePasswordPagePasswordConfirmInput': function (event, template) {
var password = $('[name="password"]').val();
var confirmPassword = $('[name="confirm"]').val();
ActiveEntry.verifyConfirmPassword(password, confirmPassword);
ActiveEntry.errorMessages.set('changePasswordError', null);
},
"submit": function (event, template) {
event.preventDefault();
var oldPassword = $('[name="oldPassword"]').val();
var password = $('[name="password"]').val();
var confirmPassword = $('[name="confirm"]').val();
ActiveEntry.verifyConfirmPassword(password, confirmPassword);
ActiveEntry.errorMessages.set('changePasswordError', null);
if (ActiveEntry.errorMessages.get('password') || ActiveEntry.errorMessages.get('confirm') || !oldPassword) {
return;
}
ActiveEntry.changePassword(oldPassword, password);
}
});
@@ -0,0 +1,5 @@
#changePassword{
input{
padding-left: 40px;
}
}
+52
View File
@@ -0,0 +1,52 @@
/**
* @summary Determines if a block of code should be displayed based on whether the logo is set to be displayed.
* @locus Client
* @memberOf Entry
* @name {{logoIsDisplayed}}
* @version 1.2.3
* @returns {Boolean}
* @example
* ```html
* {{#if logoIsDisplayed}}
* <div class="entryLogo" style="background-image: url('{{logoUrl}}')"></div>
* {{/if}}
* ```
*/
Template.registerHelper("logoIsDisplayed", function (argument){
var config = Session.get('Photonic.ActiveEntry');
if(config && config.logo && config.logo.displayed){
return config.logo.displayed;
}else{
return false;
}
});
/**
* @summary Retruns the Url of the logo asset.
* @locus Client
* @memberOf Entry
* @name {{logoUrl}}
* @version 1.2.3
* @returns {String}
* @example
* ```html
* {{#if logoIsDisplayed}}
* <div class="entryLogo" style="background-image: url('{{logoUrl}}')"></div>
* {{/if}}
* ```
*/
Template.registerHelper("logoUrl", function (argument){
var config = Session.get('Photonic.ActiveEntry');
if(config && config.logo && config.logo.url){
return config.logo.url;
}else{
return "";
}
});
Template.registerHelper("getButtonColor", function (argument){
return "background-color: " + Theme.getPaletteColor("colorB") + "; ";
});
+169
View File
@@ -0,0 +1,169 @@
// @import 'client/app/stylesheets/util/reset.lessimport';
// @import 'client/app/stylesheets/util/lesshat.lessimport';
// @import 'client/app/stylesheets/util/typography.lessimport';
// this probably wants to be moved into clinical:glass-ui
.entryPage {
input, button, select{
font-size: 14px;
line-height: 20px;
font-family: 'Open Sans', "Helvetica Neue", Helvetica, Arial, sans-serif;
font-style: 400;
padding: .75rem 0;
line-height: 1.5rem !important;
border: none;
border-radius: 0;
box-sizing: border-box;
//color: #333333;
outline: none;
padding-left: 3em;
}
}
.entryLogo{
//background-color: lightgray;
height: 200px;
width: 200px;
background-size: contain;
background-repeat: no-repeat;
margin-left: auto;
margin-right: auto;
}
.btn-primary{
background-color: forestgreen;
color: #ffffff;
}
.btn-gray{
background-color: #aaaaaa;
color: white;
}
.btn-main{
font-weight: 300;
letter-spacing: 3px;
text-transform: uppercase;
}
.input-symbol {
display: inline-block;
position: relative;
}
.entryPage {
text-align: center;
input, button{
width: 100%;
}
.fa{
position: absolute;
left: 0px;
top: 0px;
padding-left: 15px;
padding-top: 14px;
}
.checkmarkIcon{
position: absolute;
color: #831d2c;
}
.btn-gray{
width: 100%;
}
.checkmarkTitle{
padding-bottom: 100px;
}
.fa{
position: absolute;
left: 0px;
top: 0px;
padding-left: 15px;
padding-top: 16px;
// color: #555555;
}
.wrapper-auth {
//padding-top: 4em;
@media screen and (min-width: 40em) {
margin: 0 auto;
max-width: 480px;
width: 80%;
}
@media screen and (max-width: 480px) {
margin: 0 auto;
padding-left: 20px;
padding-right: 20px;
}
// .input-symbol{
// border: 1px solid gray;
// }
.title-auth {
color: black;
margin-bottom: .75rem;
}
.subtitle-auth {
color: black;
//margin: 0 15% 3rem;
margin-bottom: 2rem;
padding: 15px;
}
form {
input{
color: #333333;
height: 48px;
border-left: solid 1px !important;
}
.input-symbol {
margin-bottom: 1px;
width: 100%;
}
.btn-primary {
//margin: 1em 5% 0;
//width: 90%;
margin-top: 1em;
@media screen and (min-width: 40em) {
// margin-left: 0;
// margin-right: 0;
width: 100%;
}
}
}
.list-errors {
margin-top: -2rem;
.taskItems {
//.title-caps;
background: white;
color: red;
font-size: .625em; // 10px
margin-bottom: 1px;
padding: .7rem 0;
}
}
}
.link-auth-alt {
//.font-s1;
//.position(absolute, auto, 0, 1em, 0);
color: black;
display: inline-block;
@media screen and (min-width: 40em) {
bottom: 0;
margin-top: 1rem;
position: relative;
}
}
// @media only screen and (max-width: 704px) {
// .fa{
// left: 5%;
// }
// }
}
@@ -0,0 +1,10 @@
exports.command = function () {
this
.execute(function () {
return Meteor.logout();
}).pause(1000);
return this;
};
@@ -0,0 +1,23 @@
exports.command = function (email, password) {
this.verify.elementPresent("#entrySignIn");
if (email) {
this
.verify.elementPresent("#signInPageEmailInput")
.clearValue("#signInPageEmailInput")
.setValue("#signInPageEmailInput", email);
}
if (password) {
this
.verify.elementPresent("#signInPagePasswordInput")
.clearValue("#signInPagePasswordInput")
.setValue("#signInPagePasswordInput", password);
}
this.click("#signInToAppButton").pause(1000);
return this;
};
@@ -0,0 +1,22 @@
exports.command = function (fullname) {
this
.sectionBreak(".signOut()");
if (fullname) {
this
.verify.elementPresent("#usernameLink")
.verify.containsText("#usernameLink", fullname);
}
this
.verify.elementPresent("#logoutLink")
.click("#logoutLink").pause(1000);
if (fullname) {
this
.verify.elementPresent("#usernameLink")
.verify.containsText("#usernameLink", "Sign In");
}
return this;
};
@@ -0,0 +1,35 @@
exports.command = function (email, password, title, message) {
this
// .verify.element("#entrySignIn").to.be.visible
// .verify.element("#signInPageTitle").to.be.visible
// .verify.element("#signInPageMessage").to.be.visible
// .verify.element("#signInPageEmailInput").to.be.visible
// .verify.element("#signInPagePasswordInput").to.be.visible
// .verify.element("#signInToAppButton").to.be.visible
// .verify.element("#needAnAccountButton").to.be.visible
//
.verify.elementPresent("#entrySignIn")
.verify.elementPresent("#signInPageTitle")
.verify.elementPresent("#signInPageMessage")
.verify.elementPresent("#signInPageEmailInput")
.verify.elementPresent("#signInPagePasswordInput")
.verify.elementPresent("#signInToAppButton")
.verify.elementPresent("#needAnAccountButton");
if (email) {
this.verify.containsText("#signInPageEmailInput", email);
}
if (password) {
this.verify.containsText("#signInPageEmailInput", password);
}
if (title) {
this.verify.containsText("#signInPageTitle", title);
}
if (message) {
this.verify.containsText("#signInPageMessage", message);
}
return this;
};
@@ -0,0 +1,73 @@
<template name="entrySignIn">
<div id="entrySignIn" class="page entryPage" style="{{getOpacityWithCorner}}">
<div class="content-scrollable">
<div class="wrapper-auth">
{{#if logoIsDisplayed}}
<div id="entryAppLogo" class="entryLogo" style="background-image: url('{{logoUrl}}')"></div>
{{/if}}
{{#if isLoggedIn}}
<h1 id="signInPageTitle" class="title-auth">{{fullName}}</h1>
<div id="signInPageMessage" class="subtitle-auth">You are currently signed in.</div>
<button id="logoutButton" class="btn-primary btn-main btn-large" style="{{getButtonColor}}">Logout</button>
{{else}}
<h1 id="signInPageTitle" class="title-auth">Sign In.</h1>
<p id="signInPageMessage" class="subtitle-auth" style="{{getSignInMessageColor}}">{{{getSignInMessage}}}</p>
{{#if isLDAPSet}}
<form>
{{#if ldapErrorMessages}}
<div id="errorMessages" class="list-errors">
{{#each ldapErrorMessages}}
<div class="alert alert-danger list-item">{{this}}</div>
{{/each}}
</div>
{{/if}}
<div class="input-symbol">
<input id="signInLDAPUsernameInput" type="text" name="username" placeholder="Username" style="{{getLDAPUsernameValidationStyling}}" />
<i class="fa fa-envelope-o" title="Your Email"></i>
</div>
<br><br>
<div class="input-symbol">
<input id="signInLDAPPasswordInput" type="password" name="password" placeholder="Password" style={{getLDAPPasswordValidationStyling}} />
<span class="fa fa-lock" title="Password"></span>
</div>
</form>
<br><br>
<button id="signInLDAPToAppButton" class="btn-primary btn-main btn-large" style="{{getButtonColor}}">{{getButtonText}}</button>
{{else}}
<form>
<div class="input-symbol">
<input id="signInPageEmailInput" type="text" name="email" placeholder="Your Email" style="{{getEmailValidationStyling}}" />
<i class="fa fa-envelope-o" title="Your Email"></i>
</div>
<br><br>
<div class="input-symbol">
<input id="signInPagePasswordInput" type="password" name="password" placeholder="Password" style={{getPasswordValidationStyling}} />
<span class="fa fa-lock" title="Password"></span>
</div>
</form>
<br><br>
<button id="signInToAppButton" class="btn-primary btn-main btn-large disabledButton" disabled style="{{getButtonColor}}">{{getButtonText}}</button>
<br><br>
<button id="needAnAccountButton" class="btn-gray btn-main btn-large">Need an account?</button>
<br><br>
<button id="forgotPasswordButton" class="btn-gray btn-main btn-large">Forgot password?</button>
{{/if}}
{{/if}}
</div>
</div>
</div>
</template>
@@ -0,0 +1,205 @@
// REFACTOR: Move to ActiveRecord object
//Session.set("defaultSignInMessage", "Improve your clinical practice with checklists.");
//==================================================================================================
// ROUTER
Router.route('/entrySignIn', {
template: 'entrySignIn',
name: 'entrySignIn'
});
Router.route('/sign-in', {
template: 'entrySignIn',
name: 'signInRoute'
});
//==================================================================================================
// COMPONENT OUTPUTS
Template.entrySignIn.helpers({
getSignInMessageColor: function (){
if (ActiveEntry.errorMessages.get('signInError')) {
return "color: #a94442; background-color: #f2dede; border-color: #ebccd1;"
} else {
return "color: black;"
}
},
getSignInMessage: function (){
if (ActiveEntry.errorMessages.get('signInError')) {
return ActiveEntry.errorMessages.get('signInError');
} else {
return Session.get('defaultSignInMessage');
}
},
getButtonText: function () {
return "Sign In";
// if (ActiveEntry.errorMessages.get('signInError')){
// return ActiveEntry.errorMessages.get('signInError');
// } else {
// return "Sign In";
// }
},
getEmailValidationStyling: function () {
if (ActiveEntry.errorMessages.equals('email', "Email is required")) {
return "border: 1px solid #a94442";
} else if (ActiveEntry.errorMessages.equals('email', "Email is poorly formatted")) {
return "border: 1px solid #f2dede";
} else if (ActiveEntry.successMessages.equals('email', "Email present")) {
return "border: 1px solid green";
} else {
return "border: 1px solid gray";
}
},
getPasswordValidationStyling: function () {
if (ActiveEntry.errorMessages.equals('password', "Password is required")) {
return "border: 1px solid #a94442";
} else if (ActiveEntry.errorMessages.equals('password', Session.get('passwordWarning'))) {
return "border: 1px solid #f2dede";
} else if (ActiveEntry.successMessages.equals('password', "Password present")) {
return "border: 1px solid green";
} else {
return "border: 1px solid gray";
}
},
getLDAPUsernameValidationStyling: function() {
if (ActiveEntry.errorMessages.equals('ldapUsername', "Username is required")) {
return "border: 1px solid #a94442";
} else if (ActiveEntry.successMessages.equals('ldapUsername', "Username present")) {
return "border: 1px solid green";
} else {
return "border: 1px solid gray";
}
},
getLDAPPasswordValidationStyling: function() {
if (ActiveEntry.errorMessages.equals('ldapPassword', "Password is required")) {
return "border: 1px solid #a94442";
} else if (ActiveEntry.successMessages.equals('ldapPassword', "Password present")) {
return "border: 1px solid green";
} else {
return "border: 1px solid gray";
}
},
isLDAPSet: function() {
return Session.get('isLDAPSet');
},
ldapErrorMessages: function () {
if (ActiveEntry.errorMessages.get("ldapUsername")) {
return [ActiveEntry.errorMessages.get("ldapUsername")];
} else if(ActiveEntry.errorMessages.get("ldapPassword")) {
return [ActiveEntry.errorMessages.get("ldapPassword")];
}
return;
}
});
//==================================================================================================
// COMPONENT OUTPUTS
Template.entrySignIn.events({
'click #logoutButton': function () {
Meteor.logout();
},
'click #forgotPasswordButton': function (event) {
event.preventDefault();
ActiveEntry.reset();
Router.go('/forgotPassword');
},
"click #needAnAccountButton": function (event) {
event.preventDefault();
ActiveEntry.reset();
Router.go('/entrySignUp');
},
'keyup input[name="email"]': function (event, template) {
var email = $('input[name="email"]').val();
ActiveEntry.verifyEmail(email);
ActiveEntry.errorMessages.set('signInError', null);
setSignInButtonStyling();
},
'change input[name="email"]': function (event, template) {
var email = $('input[name="email"]').val();
ActiveEntry.verifyEmail(email);
ActiveEntry.errorMessages.set('signInError', null);
setSignInButtonStyling();
},
'keyup #signInPagePasswordInput': function (event, template) {
var password = $('input[name="password"]').val();
ActiveEntry.verifyPassword(password);
ActiveEntry.errorMessages.set('signInError', null);
setSignInButtonStyling();
},
'change #signInPagePasswordInput': function (event, template) {
var password = $('input[name="password"]').val();
ActiveEntry.verifyPassword(password);
ActiveEntry.errorMessages.set('signInError', null);
setSignInButtonStyling();
},
'keyup, change #signInLDAPUsernameInput': function (event, template) {
var username = $('#signInLDAPUsernameInput').val();
ActiveEntry.verifyLDAPUsername(username);
ActiveEntry.errorMessages.set('signInError', null);
},
'keyup, change #signInLDAPPasswordInput': function (event, template) {
var password = $('#signInLDAPPasswordInput').val();
ActiveEntry.verifyLDAPPassword(password);
ActiveEntry.errorMessages.set('signInError', null);
},
// 'submit': function (event, template) {
// event.preventDefault();
// var emailValue = template.$('[name=email]').val();
// var passwordValue = template.$('[name=password]').val();
//
// ActiveEntry.signIn(emailValue, passwordValue);
// },
'click #signInToAppButton': function (event, template){
ActiveEntry.reset();
// var emailValue = template.$('[name=email]').val();
// var passwordValue = template.$('[name=password]').val();
var emailValue = template.$('#signInPageEmailInput').val();
var passwordValue = template.$('#signInPagePasswordInput').val();
ActiveEntry.signIn(emailValue, passwordValue);
event.preventDefault();
},
'keyup #entrySignIn': function(event, template) {
if(event.keyCode == 13) {
$("#signInToAppButton").click();
$("#signInLDAPToAppButton").click();
}
},
'click #signInLDAPToAppButton': function(e, template) {
var username = template.$("#signInLDAPUsernameInput").val();
var password = template.$("#signInLDAPPasswordInput").val();
ActiveEntry.loginWithLDAP(username, password);
}
});
//==================================================================================================
// Sets SignInButton Styling according to email and password fields
function setSignInButtonStyling() {
var signInToAppButton = $("#signInToAppButton");
if ($("#signInPagePasswordInput").val() && ActiveEntry.successMessages.get('email')) {
// Set button as enable
signInToAppButton.removeClass("disabledButton");
signInToAppButton.attr("disabled", false);
} else {
signInToAppButton.addClass("disabledButton");
signInToAppButton.attr("disabled", true);
}
}
@@ -0,0 +1,31 @@
#entrySignIn{
padding: 40px;
input{
padding-left: 40px;
color: #333333 !important;
}
#errorMessages{
padding-top: .5rem;
padding-bottom: .5rem;
font-size: 14px;
box-sizing: border-box;
width: 100.5%;
margin-bottom: 15px;
color: red;
font-weight: bold;
}
.disabledButton {
border: none;
background-image: none;
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
filter: alpha(opacity=40);
-khtml-opacity: 0.40;
-moz-opacity: 0.40;
opacity: 0.40;
cursor: not-allowed;
box-shadow: none;
}
}
@@ -0,0 +1,22 @@
// async version calls method on the server
exports.command = function () {
var client = this;
this
.timeoutsAsyncScript(5000)
.executeAsync(function (data, meteorCallback) {
//return HipaaLogger.logEventObject(data);
Meteor.call("dropEntryUsers", data, function (meteorError, meteorResult) {
var response = (meteorError ? {
error: meteorError
} : {
result: meteorResult
});
meteorCallback(response);
});
}, [], function (result) {
//console.log("result.value", result.value);
//client.assert.ok(result.value);
}).pause(1000);
return this;
};
@@ -0,0 +1,11 @@
// resetEntry.js
exports.command = function () {
this
.timeoutsAsyncScript(5000)
.executeAsync(function (data, meteorCallback) {
ActiveEntry.reset();
}, []).pause(1000);
return this;
};
@@ -0,0 +1,37 @@
exports.command = function (email, password, fullName) {
this.verify.elementPresent("#entrySignUp");
if (email) {
this
.verify.elementPresent("#signUpPageEmailInput")
.clearValue("#signUpPageEmailInput")
.setValue("#signUpPageEmailInput", email);
}
if (password) {
this
.verify.elementPresent("#signUpPagePasswordInput")
.clearValue("#signUpPagePasswordInput")
.setValue("#signUpPagePasswordInput", password)
.verify.elementPresent("#signUpPagePasswordConfirmInput")
.clearValue("#signUpPagePasswordConfirmInput")
.setValue("#signUpPagePasswordConfirmInput", password);
}
if (fullName) {
this
.verify.elementPresent("#signUpPageFullNameInput")
.clearValue("#signUpPageFullNameInput")
.setValue("#signUpPageFullNameInput", fullName);
}
this.click("#signUpPageJoinNowButton").pause(300);
return this;
};
@@ -0,0 +1,31 @@
exports.command = function (email, password, fullName, message) {
this
.verify.elementPresent("#entrySignUp")
.verify.elementPresent("#signUpPageTitle")
.verify.elementPresent("#signUpPageMessage")
.verify.elementPresent("#signUpPageFullNameInput")
.verify.elementPresent("#signUpPageEmailInput")
.verify.elementPresent("#signUpPagePasswordInput")
.verify.elementPresent("#signUpPagePasswordConfirmInput")
.verify.elementPresent("#signUpPageJoinNowButton")
.verify.elementPresent("#signUpPageSignInButton");
if (email) {
this.verify.containsText("#signUpPageEmailInput", email);
}
if (password) {
this.verify.containsText("#signUpPagePasswordInput", password)
.verify.containsText("#signUpPagePasswordConfirmInput", password);
}
if (fullName) {
this.verify.containsText("#signUpPageFullNameInput", fullName);
}
if (message) {
this.verify.elementPresent("#errorMessages")
.verify.containsText("#errorMessages", message);
}
return this;
};
@@ -0,0 +1,64 @@
<template name="entrySignUp">
<div id="entrySignUp" class="page entryPage" style="{{getOpacityWithCorner}}">
<div class="content-scrollable">
<div class="wrapper-auth">
{{#if logoIsDisplayed}}
<div id="entryAppLogo" class="entryLogo" style="background-image: url('{{logoUrl}}')"></div>
{{/if}}
<h1 id="signUpPageTitle" class="title-auth">Join.</h1>
<div id="signUpPageMessage" class="subtitle-auth" style="{{getSignUpMessageColor}}">{{getSignUpMessage}}</div>
<form id="entrySignUpForm">
{{#if entryErrorMessages}}
<div id="errorMessages" class="list-errors">
{{#each entryErrorMessages}}
<div class="alert alert-danger list-item">{{this}}</div>
{{/each}}
</div>
{{/if}}
<div class="input-symbol ">
<input id="signUpPageFullNameInput" type="text" name="fullName" placeholder="Full Name" style="{{getFullNameStyling}}" />
<i class="fa fa-user" title="Full Name"></i>
</div>
<br>
<br>
<div class="input-symbol">
<input id="signUpPageEmailInput" type="email" name="email" placeholder="Email Address" style="{{getEmailStyling}}" />
<i class="fa fa-envelope-o" title="Your Email"></i>
</div>
<br>
<br>
<div class="input-symbol ">
<input id="signUpPagePasswordInput" type="password" name="password" placeholder="Password" style="{{getPasswordStyling}}" />
<span class="fa fa-lock" title="Password"></span>
<!-- <span class="icon-lock" title="Password"></span> -->
</div>
<br>
<br>
<div class="input-symbol">
<input id="signUpPagePasswordConfirmInput" type="password" name="confirm" placeholder="Confirm Password" style="{{getConfirmPasswordStyling}}" />
<span class="fa fa-lock" title="Confirm Password"></span>
<!-- <span class="icon-lock" title="Confirm Password"></span> -->
</div>
</form>
<br>
<br>
<button id="signUpPageJoinNowButton" type="submit" class="btn-primary btn-main btn-large" style="{{getButtonColor}}">Join Now</button>
<br>
<br>
<button id="signUpPageSignInButton" class="btn-gray btn-main btn-large">Have an account? Sign in</button>
</div>
<!-- <a id="signUpPageSignInButton" href="{{pathFor 'entrySignIn'}}" class="link-auth-alt">Have an account? Sign in</a> -->
</div>
</div>
</template>
@@ -0,0 +1,171 @@
//==================================================================================================
// ROUTER
Router.route('/entrySignUp', {
template: 'entrySignUp',
name: 'entrySignUp'
});
Router.route('/sign-up', {
template: 'entrySignUp',
name: 'signUpRoute'
});
//==================================================================================================
Template.entrySignUp.helpers({
getSignUpMessageColor: function (){
if (ActiveEntry.errorMessages.get('signInError')) {
return "color: #a94442; background-color: #f2dede; border-color: #ebccd1;";
} else {
return "color: black;";
}
},
getSignUpMessage: function (){
if (ActiveEntry.errorMessages.get('signInError')) {
return ActiveEntry.errorMessages.get('signInError');
} else {
return Session.get('defaultSignInMessage');
}
},
entryErrorMessages: function () {
var allErrorMessages = Object.keys(ActiveEntry.errorMessages.all()).filter(function(key) {
return key !== "signInError" && ActiveEntry.errorMessages.get(key);
});
if (allErrorMessages.length > 0) {
var errorMessage = ActiveEntry.errorMessages.get(allErrorMessages[0]);
if (errorMessage) {
return [errorMessage];
}
}
return;
},
getButtonText: function () {
if (ActiveEntry.errorMessages.get('signInError')) {
return ActiveEntry.errorMessages.get('signInError').message;
} else {
return "Sign In";
}
},
getEmailStyling: function () {
if (ActiveEntry.errorMessages.equals('email', "Email is required")) {
return "border: 1px solid #a94442";
} else if (ActiveEntry.errorMessages.equals('email', "Email is poorly formatted")) {
return "border: 1px solid #f2dede";
} else if (ActiveEntry.successMessages.equals('email', "Email present")) {
return "border: 1px solid green";
} else {
return "border: 1px solid gray";
}
},
getPasswordStyling: function () {
if (ActiveEntry.errorMessages.equals('password', "Password is required")) {
return "border: 1px solid #a94442";
} else if (ActiveEntry.errorMessages.equals('password', Session.get('passwordWarning'))) {
return "border: 1px solid #f2dede";
} else if (ActiveEntry.successMessages.equals('password', "Password present")) {
return "border: 1px solid green";
} else {
return "border: 1px solid gray";
}
},
getConfirmPasswordStyling: function () {
if (ActiveEntry.errorMessages.equals('confirm', "Password is required")) {
return "border: 1px solid #a94442";
} else if (ActiveEntry.errorMessages.equals('confirm', "Passwords do not match")) {
return "border: 1px solid #a94442";
} else if (ActiveEntry.errorMessages.equals('confirm', "Password is weak")) {
return "border: 1px solid #f2dede";
} else if (ActiveEntry.successMessages.equals('confirm', "Passwords match")) {
return "border: 1px solid green";
} else {
return "border: 1px solid gray";
}
},
getFullNameStyling: function () {
if (ActiveEntry.errorMessages.equals('fullName', "Name is required")) {
return "border: 1px solid #a94442";
} else if (ActiveEntry.errorMessages.equals('fullName', "Name is probably not complete")) {
return "border: 1px solid #f2dede";
} else if (ActiveEntry.successMessages.equals('fullName', "Name present")) {
return "border: 1px solid green";
} else {
return "border: 1px solid gray";
}
}
});
Template.entrySignUp.events({
"click #signUpPageSignInButton": function (event) {
event.preventDefault();
ActiveEntry.reset();
Router.go('/entrySignIn');
},
'change, keyup #signUpPageEmailInput': function (event, template) {
var email = $('[name="email"]').val();
ActiveEntry.verifyEmail(email);
ActiveEntry.errorMessages.set('signInError', null);
},
'change, keyup #signUpPagePasswordInput': function (event, template) {
var password = $('[name="password"]').val();
ActiveEntry.verifyPassword(password);
ActiveEntry.errorMessages.set('signInError', null);
},
'change, keyup #signUpPagePasswordConfirmInput': function (event, template) {
var password = $('[name="password"]').val();
var confirmPassword = $('[name="confirm"]').val();
// var password = $('#signUpPagePasswordInput').val();
// var confirmPassword = $('#signUpPagePasswordConfirmInput').val();
ActiveEntry.verifyConfirmPassword(password, confirmPassword);
ActiveEntry.errorMessages.set('signInError', null);
},
'change, keyup #signUpPageFullNameInput': function (event, template) {
var fullName = template.$('[name="fullName"]').val();
ActiveEntry.verifyFullName(fullName);
ActiveEntry.errorMessages.set('signInError', null);
},
'click #signUpPageJoinNowButton': function (event, template) {
ActiveEntry.signUp(
$('#signUpPageEmailInput').val(),
$('#signUpPagePasswordInput').val(),
$('#signUpPagePasswordConfirmInput').val(),
$('#signUpPageFullNameInput').val()
);
},
'keyup #entrySignUp': function(event, template) {
if(event.keyCode == 13) {
ActiveEntry.verifyFullName($("#signUpPageFullNameInput").val());
ActiveEntry.verifyEmail($("#signUpPageEmailInput").val());
ActiveEntry.verifyPassword($("#signUpPagePasswordInput").val());
ActiveEntry.verifyConfirmPassword($("#signUpPagePasswordInput").val(), $("#signUpPagePasswordConfirmInput").val());
if (!ActiveEntry.errorMessages.get('signInError') &&
ActiveEntry.successMessages.get('fullName') &&
ActiveEntry.successMessages.get('email') &&
ActiveEntry.successMessages.get('password') &&
ActiveEntry.successMessages.get('confirm')) {
$("#signUpPageJoinNowButton").click();
}
}
}
});
Template.entrySignUp.onRendered(function() {
// Password strength meter for password inputs
if (passwordValidationSettings.showPasswordStrengthIndicator) {
this.$('#signUpPagePasswordInput').pwstrength(passwordValidationSettings.pwstrengthOptions);
}
// Update password warning message if zxcvbn is active and zxcvbn function is defined
if(passwordValidationSettings.requireStrongPasswords) {
Session.set('passwordWarning', 'Password is weak');
}
});
@@ -0,0 +1,12 @@
#entrySignUp{
padding: 40px;
input{
padding-left: 40px !important;
color: black;
}
}
#entrySignUp .progress{
height: 5px;
margin-bottom: 1px
}
@@ -0,0 +1,4 @@
exports.command = function () {
this
.verify.elementPresent("#forgotPassword"); return this;
};
@@ -0,0 +1,30 @@
<template name="forgotPassword">
<div id="forgotPassword" class="page entryPage" style="{{getOpacityWithCorner}}">
<div class="content-scrollable">
<div class="wrapper-auth">
<div class="entryLogo" style="background-image: url('{{getLogoUrl}}')"></div>
<h1 id="signInPageTitle" class="title-auth">Forgot Password</h1>
<div id="signInPageMessage" class="subtitle-auth" >Improve your clinical practice with checklists.</div>
<p id="signInPageMessage" class="subtitle-auth" style="{{getForgotPasswordMessageColor}}">{{{getForgotPasswordMessage}}}</p>
<form>
<div class="input-symbol">
<input id="signInPageEmailInput" type="email" name="email" placeholder="Your Email" style="{{getForgotPasswordStyle}}" />
<i class="fa fa-envelope-o" title="Your Email"></i>
</div>
<br><br>
<button id="sendReminderButton" type="submit" class="btn-gray btn-main btn-large" style="{{getButtonColor}}">Send Reminder</button><br><br>
{{#if forgotPasswordNotification}}
<div class="alert alert-success">
{{{forgotPasswordNotification}}}
</div>
{{/if}}
</form>
</div>
</div>
</div>
</template>
@@ -0,0 +1,36 @@
//==========================================
Router.route('/forgotPassword', {
name: "forgotPassword",
template: "forgotPassword"
});
Template.forgotPassword.helpers({
getForgotPasswordMessageColor: function (){
if (ActiveEntry.errorMessages.get('forgotPassword')) {
return "color: #a94442; background-color: #f2dede; border-color: #ebccd1;"
} else {
return "color: black;"
}
},
getForgotPasswordMessage: function (){
return ActiveEntry.errorMessages.get('forgotPassword');
},
getForgotPasswordStyle: function (){
return "border: 1px solid gray";
},
forgotPasswordNotification: function() {
return ActiveEntry.successMessages.get("forgotPassword");
}
});
Template.forgotPassword.events({
"submit": function (event, template) {
event.preventDefault();
console.log('send reminder!');
ActiveEntry.successMessages.set("forgotPassword", "Your password reset email is sending...");
var emailAddress = $('#signInPageEmailInput').val();
ActiveEntry.forgotPassword(emailAddress);
}
});
@@ -0,0 +1,5 @@
#forgotPassword{
input{
padding-left: 40px;
}
}
@@ -0,0 +1,42 @@
<template name="resetPassword">
{{#if resetPassword}}
<div id="resetPassword" class="page entryPage" style="{{getOpacityWithCorner}}">
<div class="content-scrollable">
<div class="wrapper-auth">
<div class="entryLogo" style="background-image: url('{{getLogoUrl}}')"></div>
<h1 id="signInPageTitle" class="title-auth">Reset Password</h1>
<p id="signInPageMessage" class="subtitle-auth" style="{{getResetPasswordInMessageColor}}">{{{getResetPasswordMessage}}}</p>
<form>
{{#if resetPasswordErrorMessages}}
<div id="errorMessages" class="list-errors">
{{#each resetPasswordErrorMessages}}
<div class="alert alert-danger list-item">{{this}}</div>
{{/each}}
</div>
{{/if}}
<div class="input-symbol ">
<input id="resetPasswordInput" type="password" name="password" placeholder="Password" style="{{getPasswordStyling}}" />
<span class="fa fa-lock" title="Password"></span>
<!-- <span class="icon-lock" title="Password"></span> -->
</div>
<br>
<br>
<div class="input-symbol">
<input id="resetPasswordConfirmInput" type="password" name="confirm" placeholder="Confirm Password" style="{{getConfirmPasswordStyling}}" />
<span class="fa fa-lock" title="Confirm Password"></span>
<!-- <span class="icon-lock" title="Confirm Password"></span> -->
</div>
<br>
<br>
</form>
<button id="resetPasswordButton" type="submit" class="btn-gray btn-main btn-large" style="{{getButtonColor}}">Reset Password</button><br><br>
</div>
</div>
</div>
{{/if}}
</template>
@@ -0,0 +1,67 @@
Router.route('/resetPassword/:token', {
template: 'resetPassword',
name: 'resetPassword',
onBeforeAction: function() {
var token = this.params.token;
Session.set('_resetPasswordToken', token);
this.next();
}
});
// Reset password template
Template.resetPassword.helpers({
getResetPasswordInMessageColor: function (){
if (ActiveEntry.errorMessages.get('resetPasswordError')) {
return "color: #a94442; background-color: #f2dede; border-color: #ebccd1;"
} else {
return "color: black;"
}
},
getResetPasswordMessage: function (){
if (ActiveEntry.errorMessages.get('resetPasswordError')) {
return ActiveEntry.errorMessages.get('resetPasswordError');
} else {
return Session.get('defaultSignInMessage');
}
},
resetPassword: function(){
return Session.get('_resetPasswordToken');
},
resetPasswordErrorMessages: function() {
if (ActiveEntry.errorMessages.get("password")) {
return [ActiveEntry.errorMessages.get("password")];
}
if (ActiveEntry.errorMessages.get("confirm")) {
return [ActiveEntry.errorMessages.get("confirm")];
}
return;
}
});
Template.resetPassword.events({
'keyup #resetPasswordInput': function (event, template) {
var password = $('#resetPasswordInput').val();
ActiveEntry.verifyPassword(password);
ActiveEntry.errorMessages.set('resetPasswordError', null);
},
'keyup #resetPasswordConfirmInput': function (event, template) {
var password = $('#resetPasswordInput').val();
var confirmPassword = $('#resetPasswordConfirmInput').val();
ActiveEntry.verifyConfirmPassword(password, confirmPassword);
ActiveEntry.errorMessages.set('resetPasswordError', null);
},
'click #resetPasswordButton': function(e, template) {
e.preventDefault();
var password = $('#resetPasswordInput').val();
var passwordConfirm = $('#resetPasswordConfirmInput').val();
if (ActiveEntry.errorMessages.get('password') || ActiveEntry.errorMessages.get('confirm')) {
return;
}
ActiveEntry.resetPassword(password, passwordConfirm);
}
});
+48
View File
@@ -0,0 +1,48 @@
if (Meteor.isClient) {
Accounts.onResetPasswordLink(function (token, done){
console.log('Accounts.onResearchPasswordLink');
console.log('Sending reset password email...');
console.log('NOT IMPLEMENTED YET. PLEASE LOG AN ISSUE');
console.log('token: ' + token);
done();
});
Accounts.onEnrollmentLink(function (token, done){
console.log('Accounts.onResearchPasswordLink');
console.log('Sending enrollment email...');
console.log('NOT IMPLEMENTED YET. PLEASE LOG AN ISSUE');
console.log('token: ' + token);
done();
});
Accounts.onEmailVerificationLink(function (token, done){
console.log('Accounts.onEmailVerificationLink');
console.log('Sending verification email...');
console.log('NOT IMPLEMENTED YET. PLEASE LOG AN ISSUE');
console.log('token: ' + token);
done();
});
}
if (Meteor.isServer){
// Support for playing D&D: Roll 3d6 for dexterity
Accounts.onCreateUser(function(options, user) {
var d6 = function () { return Math.floor(Random.fraction() * 6) + 1; };
user.dexterity = d6() + d6() + d6();
user.role = "user";
// We still want the default hook's 'profile' behavior.
if (options.profile){
user.profile = options.profile;
}
return user;
});
}
+545
View File
@@ -0,0 +1,545 @@
ActiveEntry = {};
ActiveEntry.isAbc = function () {
return "abc";
};
if (Meteor.isClient) {
Session.setDefault('Photonic.ActiveEntry', {
logo: {
url: "https://upload.wikimedia.org/wikipedia/commons/1/1a/Photon-photon_scattering.png",
displayed: true
},
signIn: {
displayFullName: true,
destination: "/"
},
signUp: {
destination: "/"
},
themeColors: {
primary: ""
},
passwordOptions: {
showPasswordStrengthIndicator: true,
requireRegexValidation: true,
//requireStrongPasswords: false
passwordHistoryCount: 6,
failedAttemptsLimit: 5,
passwordExpirationDays: 90,
inactivityPeriodDays: 180,
expireTimeInMinute: 30
}
});
ActiveEntry.errorMessages = new ReactiveDict('errorMessages');
ActiveEntry.errorMessages.set('signInError', false);
// Success messages
ActiveEntry.successMessages = new ReactiveDict('successMessages');
// Change password warning message according to whether zxcvbn is turned on
Session.set('passwordWarning', 'Password must have at least 8 characters. It must contain at least 1 uppercase, 1 lowercase, 1 number and 1 special character.');
// Activate LDAP if ldap url and port is set in settings.json
Meteor.call('isLDAPSet', function(error, isSet) {
Session.set('isLDAPSet', isSet);
});
}
if (Meteor.isServer) {
LDAP_DEFAULTS = {};
LDAP_DEFAULTS.url = Meteor.settings.ldap && Meteor.settings.ldap.url;
LDAP_DEFAULTS.port = Meteor.settings.ldap && Meteor.settings.ldap.port;
}
ActiveEntry.configure = function (configObject) {
if (Meteor.isClient) {
// Set passwordOptions if they are not defined
if (!configObject.passwordOptions) {
configObject.passwordOptions = {
showPasswordStrengthIndicator: true,
requireRegexValidation: false,
//requireStrongPasswords: false
passwordHistoryCount: 6,
failedAttemptsLimit: 5,
passwordExpirationDays: 90,
inactivityPeriodDays: 180,
expireTimeInMinute: 30
}
}
Session.set('Photonic.ActiveEntry', configObject);
}
};
ActiveEntry.verifyPassword = function (password) {
if (password.length === 0) {
ActiveEntry.errorMessages.set('password', 'Password is required');
ActiveEntry.successMessages.set('password', null);
} else if (!checkPasswordStrength(password)) {
ActiveEntry.errorMessages.set('password', Session.get('passwordWarning'));
ActiveEntry.successMessages.set('password', null);
} else {
ActiveEntry.errorMessages.set('password', null);
ActiveEntry.successMessages.set('password', 'Password present');
}
};
ActiveEntry.verifyConfirmPassword = function (password, confirmPassword) {
// we have two different logic checks happening in this function
// would be reasonable to separate them out into separate functions
if (confirmPassword === "") {
ActiveEntry.errorMessages.set('confirm', 'Password is required');
ActiveEntry.successMessages.set('confirm', null);
} else if (confirmPassword === password) {
ActiveEntry.errorMessages.set('confirm', null);
ActiveEntry.successMessages.set('confirm', 'Passwords match');
} else {
ActiveEntry.errorMessages.set('confirm', 'Passwords do not match');
ActiveEntry.successMessages.set('confirm', null);
}
};
ActiveEntry.verifyEmail = function (email) {
if (email.length === 0) {
ActiveEntry.errorMessages.set('email', 'Email is required');
ActiveEntry.successMessages.set('email', null);
} else if (email.indexOf("@") === -1){
ActiveEntry.errorMessages.set('email', 'Email is poorly formatted');
ActiveEntry.successMessages.set('email', null);
} else if (email.indexOf("@") >= 0){
ActiveEntry.errorMessages.set('email', null);
ActiveEntry.successMessages.set('email', 'Email present');
}
};
ActiveEntry.verifyFullName = function (fullName) {
if (fullName.length === 0) {
ActiveEntry.errorMessages.set('fullName', 'Name is required');
ActiveEntry.successMessages.set('fullName', null);
} else if (fullName.indexOf(" ") === -1){
ActiveEntry.errorMessages.set('fullName', 'Name is probably not complete');
ActiveEntry.successMessages.set('fullName', null);
} else if (fullName.indexOf(" ") >= 0){
//ActiveEntry.errorMessages.set('fullName', 'Name present');
ActiveEntry.errorMessages.set('fullName', null);
ActiveEntry.successMessages.set('fullName', 'Name present');
}
};
ActiveEntry.verifyLDAPUsername = function(username) {
if (username === "") {
ActiveEntry.errorMessages.set("ldapUsername", "Username is required");
ActiveEntry.successMessages.set("ldapUsername", null);
} else {
ActiveEntry.errorMessages.set("ldapUsername", null);
ActiveEntry.successMessages.set("ldapUsername", "Username present");
}
};
ActiveEntry.verifyLDAPPassword = function(password) {
if (password === "") {
ActiveEntry.errorMessages.set("ldapPassword", "Password is required");
ActiveEntry.successMessages.set("ldapPassword", null);
} else {
ActiveEntry.errorMessages.set("ldapPassword", null);
ActiveEntry.successMessages.set("ldapPassword", "Password present");
}
};
ActiveEntry.signIn = function (emailValue, passwordValue){
ActiveEntry.verifyPassword(passwordValue);
ActiveEntry.verifyEmail(emailValue);
var signInArgs = {email: emailValue, password: passwordValue};
var ActiveEntryConfig = Session.get('Photonic.ActiveEntry');
var passwordOptions = ActiveEntryConfig && ActiveEntryConfig.passwordOptions;
Meteor.call("isAccountInactive",emailValue, passwordOptions.inactivityPeriodDays, function(error, isAccountInactive) {
if (error) {
console.warn(error.message);
return;
}
if (isAccountInactive) {
// Lock account
ActiveEntry.lockAccount(signInArgs);
} else {
// Check account is locked
ActiveEntry.isAccountLocked(signInArgs, passwordOptions);
}
});
};
ActiveEntry.lockAccount = function(signInArgs) {
var emailValue = signInArgs && signInArgs.email;
if (!emailValue) {
return;
}
Meteor.call("lockAccount", emailValue);
ActiveEntry.errorMessages.set('signInError', "Your account has been locked due to inactivity.");
};
ActiveEntry.isAccountLocked = function(signInArgs, passwordOptions) {
var emailValue = signInArgs && signInArgs.email;
if (!emailValue) {
return;
}
Meteor.call("isAccountLocked", emailValue, function (error, isAccountLocked) {
if (error) {
console.warn(error.message);
return;
}
if (isAccountLocked) {
ActiveEntry.errorMessages.set('signInError', "Your account has been locked.");
return;
}
// Get failed attempts count
ActiveEntry.getFailedAttemptsCount(signInArgs, passwordOptions);
});
};
ActiveEntry.getFailedAttemptsCount = function(signInArgs, passwordOptions) {
var emailValue = signInArgs && signInArgs.email;
if (!emailValue) {
return;
}
Meteor.call("getFailedAttemptsCount", emailValue, function(error, failedAttemptsCount) {
if (error) {
console.warn(error.message);
return;
}
if (failedAttemptsCount != passwordOptions.failedAttemptsLimit) {
// Login with password
ActiveEntry.loginWithPassword(signInArgs, passwordOptions);
} else {
ActiveEntry.errorMessages.set('signInError', "Your account has been locked.");
}
});
};
ActiveEntry.loginWithPassword = function(signInArgs, passwordOptions) {
var emailValue = signInArgs && signInArgs.email;
var password = signInArgs && signInArgs.password;
if (!emailValue || !password) {
return;
}
Meteor.loginWithPassword(emailValue, password, function (loginError, result) {
if (loginError) {
// Login failed
if (loginError.error == 403) {
ActiveEntry.updateFailedAttempts(signInArgs, passwordOptions, loginError);
}
return;
}
// Reset failed attempts
Meteor.call("resetFailedAttempts", emailValue);
// Check password expiration
ActiveEntry.isPasswordExpired(passwordOptions);
});
};
ActiveEntry.isPasswordExpired = function(passwordOptions) {
// if password expired, route to changePassword page
Meteor.call("isPasswordExpired", passwordOptions.passwordExpirationDays, function(error, isPasswordExpired) {
if (error) {
console.warn(error.message);
return;
}
// Update last login time
Meteor.call("updateLastLoginDate");
if (isPasswordExpired) {
ActiveEntry.errorMessages.set('changePasswordError', 'Your password expired. Please change your password.');
Router.go('/changePassword');
} else {
var ActiveEntryConfig = Session.get('Photonic.ActiveEntry');
Router.go(ActiveEntryConfig.signIn.destination);
}
});
};
ActiveEntry.updateFailedAttempts = function(signInArgs, passwordOptions, loginError) {
var emailValue = signInArgs && signInArgs.email;
if (!emailValue) {
return;
}
Meteor.call("updateFailedAttempts", emailValue, passwordOptions.failedAttemptsLimit, function(error, failedAttemptCount) {
if (error) {
console.warn(error.message);
return;
}
if (failedAttemptCount == passwordOptions.failedAttemptsLimit) {
ActiveEntry.errorMessages.set('signInError', "Too many failed login attempts. Your account has been locked.");
} else if (failedAttemptCount < passwordOptions.failedAttemptsLimit) {
ActiveEntry.errorMessages.set('signInError', loginError.message + "<br />" +(passwordOptions.failedAttemptsLimit - failedAttemptCount) + " attempts remaining.");
} else {
ActiveEntry.errorMessages.set('signInError', loginError.message);
}
});
};
ActiveEntry.loginWithLDAP = function(username, password) {
ActiveEntry.verifyLDAPUsername(username);
ActiveEntry.verifyLDAPPassword(password);
ActiveEntry.errorMessages.set('signInError', null);
if (ActiveEntry.errorMessages.get("ldapUsername") || ActiveEntry.errorMessages.get("ldapPassword")) {
return;
}
Meteor.loginWithLDAP(username, password, {
// The dn value depends on what you want to search/auth against
// The structure will depend on how your ldap server
// is configured or structured.
dn: "uid=" + username + ",ou=users,ou=system",
// The search value is optional. Set it if your search does not
// work with the bind dn.
searchResultsProfileMap: [
{
resultKey: 'cn',
profileProperty: 'fullName'
},
{
resultKey: 'mail',
profileProperty: 'email'
}
]
}, function(error) {
if (error) {
ActiveEntry.errorMessages.set('signInError', error.errorType+" ["+error.error+"]");
return;
}
ActiveEntry.errorMessages.set('signInError', null);
// Update last login time
Meteor.call("updateLastLoginDate");
var ActiveEntryConfig = Session.get('Photonic.ActiveEntry');
Router.go(ActiveEntryConfig.signIn.destination);
});
};
ActiveEntry.signUp = function (emailValue, passwordValue, confirmPassword, fullName){
ActiveEntry.verifyEmail(emailValue);
ActiveEntry.verifyPassword(passwordValue);
ActiveEntry.verifyConfirmPassword(passwordValue, confirmPassword);
ActiveEntry.verifyFullName(fullName);
ActiveEntry.errorMessages.set('signInError', null);
var errorIsFound = false;
Object.keys(ActiveEntry.errorMessages.keys).forEach(function(key) {
if (ActiveEntry.errorMessages.get(key) !== "null" && ActiveEntry.errorMessages.get(key) !== null) {
errorIsFound = true;
}
});
if(errorIsFound) {
return;
}
// Capitalize first letter of every word in fullName
var capitalizedFullName = fullName.replace(/[^\s]+/g, function(str){
return str.substr(0,1).toUpperCase()+str.substr(1).toLowerCase();
});
Accounts.createUser({
email: emailValue,
password: passwordValue,
profile: {
fullName: capitalizedFullName
}
}, function (error, result) {
if (error) {
ActiveEntry.errorMessages.set('signInError', error.message);
return;
}
// Add password in previousPasswords field
ActiveEntry.insertHashedPassword(passwordValue);
// Update password set date
ActiveEntry.updatePasswordSetDate();
// Update last login time
Meteor.call("updateLastLoginDate");
var ActiveEntryConfig = Session.get('Photonic.ActiveEntry');
Router.go(ActiveEntryConfig.signUp.destination);
});
};
ActiveEntry.changePassword = function(oldPassword, password) {
Meteor.call("checkPasswordExistence", new String(password).hashCode(), function(error, isPasswordExisted) {
if (error) {
console.warn(error.message);
ActiveEntry.errorMessages.set('changePasswordError', error.message);
return;
}
if (isPasswordExisted) {
ActiveEntry.errorMessages.set('changePasswordError', 'Password is used before. Please change your new password.');
} else {
ActiveEntry.errorMessages.set('changePasswordError', null);
// If password is not found in password history, change the password
Accounts.changePassword(oldPassword, password, function(error) {
if (error) {
console.warn(error);
ActiveEntry.errorMessages.set('changePasswordError', error.message);
return;
}
// Save the new password
ActiveEntry.insertHashedPassword(password);
// Update password expiration date
ActiveEntry.updatePasswordSetDate();
// Logout
ActiveEntry.signOut();
// Go to signIn page for new entry
Router.go('/entrySignIn');
});
}
});
};
ActiveEntry.forgotPassword = function(emailAddress) {
ActiveEntry.verifyEmail(emailAddress);
ActiveEntry.errorMessages.set("forgotPassword", null);
ActiveEntry.successMessages.set("forgotPassword", null);
if (ActiveEntry.errorMessages.get("email")) {
return;
}
Accounts.forgotPassword({email:emailAddress }, function(error){
if (error) {
console.warn(error.message);
ActiveEntry.errorMessages.set("forgotPassword", error.message);
ActiveEntry.successMessages.set("forgotPassword", null);
return;
}
// Show email sent notification
ActiveEntry.successMessages.set("forgotPassword", "Your password reset email is sent to <strong>"+emailAddress+"</strong>");
});
};
ActiveEntry.resetPassword = function(passwordValue, confirmPassword) {
ActiveEntry.verifyPassword(passwordValue);
ActiveEntry.verifyConfirmPassword(passwordValue, confirmPassword);
ActiveEntry.errorMessages.set("resetPassword", null);
// Check error messages
if (ActiveEntry.errorMessages.get("password") || ActiveEntry.errorMessages.get("confirm")) {
return;
}
var ActiveEntryConfig = Session.get('Photonic.ActiveEntry');
var passwordOptions = ActiveEntryConfig && ActiveEntryConfig.passwordOptions;
// Check token is expired
Meteor.call('checkResetTokenIsExpired', Session.get('_resetPasswordToken'), passwordOptions.expireTimeInMinute, function(error, isTokenExpired) {
if (error) {
console.log(error.message);
return;
}
if (isTokenExpired) {
console.log("Your link is expired");
// Go to forgotPassword to create a new reset link
ActiveEntry.errorMessages.set("forgotPassword", 'Your link is expired. Please create a new reset link.');
Router.go('/forgotPassword');
return;
}
// Check password history
Meteor.call("checkResetPasswordExistence", new String(passwordValue).hashCode(), Session.get('_resetPasswordToken'), function(error, isPasswordExisted) {
if (error) {
console.warn(error.message);
ActiveEntry.errorMessages.set('resetPasswordError', error.message);
return;
}
if (isPasswordExisted) {
ActiveEntry.errorMessages.set('resetPasswordError', 'Password is used before. Please change your new password.');
} else {
ActiveEntry.errorMessages.set('resetPasswordError', null);
Accounts.resetPassword(Session.get('_resetPasswordToken'), passwordValue, function(error) {
if (error) {
ActiveEntry.errorMessages.set("resetPassword", error.message);
return;
}
Session.set('_resetPasswordToken', null);
// Save the new password
ActiveEntry.insertHashedPassword(passwordValue);
// Update password expiration date
ActiveEntry.updatePasswordSetDate();
// Update last login time
Meteor.call("updateLastLoginDate");
var ActiveEntryConfig = Session.get('Photonic.ActiveEntry');
Router.go(ActiveEntryConfig.signIn.destination);
});
}
});
});
};
// Insert hashed password in previousPasswords fields
ActiveEntry.insertHashedPassword = function(passwordValue) {
var ActiveEntryConfig = Session.get('Photonic.ActiveEntry');
var passwordHistoryCount = ActiveEntryConfig && ActiveEntryConfig.passwordOptions && ActiveEntryConfig.passwordOptions.passwordHistoryCount || 6;
Meteor.call("insertHashedPassword", [new String(passwordValue).hashCode(),passwordHistoryCount]);
};
ActiveEntry.updatePasswordSetDate = function() {
Meteor.call("updatePasswordSetDate");
};
ActiveEntry.signOut = function (){
Meteor.logout();
};
ActiveEntry.reset = function (){
ActiveEntry.errorMessages.set('signInError', false);
ActiveEntry.errorMessages.set('fullName', false);
ActiveEntry.errorMessages.set('email', false);
ActiveEntry.errorMessages.set('confirm', false);
ActiveEntry.errorMessages.set('password', false);
};
ActiveEntry.logoIsDisplayed = function (){
var ActiveEntryConfig = Session.get('Photonic.ActiveEntry');
return ActiveEntryConfig.logo.displayed;
};
@@ -0,0 +1,59 @@
passwordValidationSettings = {};
function getPasswordValidationSettings () {
var ActiveEntryConfiguration = Session.get('Photonic.ActiveEntry');
var validationSettings = {};
validationSettings.showPasswordStrengthIndicator = ActiveEntryConfiguration && ActiveEntryConfiguration.passwordOptions && ActiveEntryConfiguration.passwordOptions.showPasswordStrengthIndicator || false;
validationSettings.requireRegexValidation = ActiveEntryConfiguration && ActiveEntryConfiguration.passwordOptions && ActiveEntryConfiguration.passwordOptions.requireRegexValidation || false;
if (validationSettings.showPasswordStrengthIndicator) {
// Set password strength meter options
validationSettings.pwstrengthOptions = {
common: {
minChar: 8
},
ui: {
showVerdictsInsideProgressBar: true,
showStatus: true
}
};
}
// Check if codetheweb:zxcvbn is defined
if (typeof(zxcvbn) === typeof(Function)) {
validationSettings.requireStrongPasswords = ActiveEntryConfiguration && ActiveEntryConfiguration.passwordOptions && ActiveEntryConfiguration.passwordOptions.requireStrongPasswords || false;
// Set zxcvbn in pw strength meter
if (validationSettings.showPasswordStrengthIndicator) {
validationSettings.pwstrengthOptions.common.zxcvbn = passwordValidationSettings.requireStrongPasswords;
}
}
return validationSettings;
}
Meteor.startup(function() {
passwordValidationSettings = getPasswordValidationSettings();
});
checkPasswordStrength = function(password) {
if (passwordValidationSettings.requireStrongPasswords) {
// Check zxcvbn
var zxcvbnResult = zxcvbn(password);
if (zxcvbnResult && zxcvbnResult.score > 2) {
return true;
}
return false;
} else if (passwordValidationSettings.requireRegexValidation) {
// Apply validation rule
var result = password.search(/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*])[0-9a-zA-Z!@#$%^&*]{8,}$/i);
if (result > -1) {
return true;
}
return false;
}
return true;
};
@@ -0,0 +1,10 @@
String.prototype.hashCode = function() {
var hash = 0, i, chr, len;
if (this.length === 0) return hash;
for (i = 0, len = this.length; i < len; i++) {
chr = this.charCodeAt(i);
hash = ((hash << 5) - hash) + chr;
hash |= 0; // Convert to 32bit integer
}
return hash;
};
@@ -0,0 +1,737 @@
/*!
* jQuery Password Strength plugin for Twitter Bootstrap
*
* Copyright (c) 2008-2013 Tane Piper
* Copyright (c) 2013 Alejandro Blanco
* Dual licensed under the MIT and GPL licenses.
*/
(function (jQuery) {
// Source: src/rules.js
var rulesEngine = {};
try {
if (!jQuery && module && module.exports) {
var jQuery = require("jquery"),
jsdom = require("jsdom").jsdom;
jQuery = jQuery(jsdom().parentWindow);
}
} catch (ignore) {}
(function ($, rulesEngine) {
"use strict";
var validation = {};
rulesEngine.forbiddenSequences = [
"0123456789", "abcdefghijklmnopqrstuvwxyz", "qwertyuiop", "asdfghjkl",
"zxcvbnm", "!@#$%^&*()_+"
];
validation.wordNotEmail = function (options, word, score) {
if (word.match(
/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i
)) {
return score;
}
return 0;
};
validation.wordLength = function (options, word, score) {
var wordlen = word.length,
lenScore = Math.pow(wordlen, options.rules.raisePower);
if (wordlen < options.common.minChar) {
lenScore = (lenScore + score);
}
return lenScore;
};
validation.wordSimilarToUsername = function (options, word, score) {
var username = $(options.common.usernameField).val();
if (username && word.toLowerCase().match(username.replace(
/[\-\[\]\/\{\}\(\)\*\+\=\?\:\.\\\^\$\|\!\,]/g, "\\$&").toLowerCase())) {
return score;
}
return 0;
};
validation.wordTwoCharacterClasses = function (options, word, score) {
if (word.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/) ||
(word.match(/([a-zA-Z])/) && word.match(/([0-9])/)) ||
(word.match(/(.[!,@,#,$,%,\^,&,*,?,_,~])/) && word.match(/[a-zA-Z0-9_]/))) {
return score;
}
return 0;
};
validation.wordRepetitions = function (options, word, score) {
if (word.match(/(.)\1\1/)) {
return score;
}
return 0;
};
validation.wordSequences = function (options, word, score) {
var found = false,
j;
if (word.length > 2) {
$.each(rulesEngine.forbiddenSequences, function (idx, seq) {
if (found) {
return;
}
var sequences = [seq, seq.split('').reverse().join('')];
$.each(sequences, function (idx, sequence) {
for (j = 0; j < (word.length - 2); j += 1) { // iterate the word trough a sliding window of size 3:
if (sequence.indexOf(word.toLowerCase().substring(j, j + 3)) > -1) {
found = true;
}
}
});
});
if (found) {
return score;
}
}
return 0;
};
validation.wordLowercase = function (options, word, score) {
return word.match(/[a-z]/) && score;
};
validation.wordUppercase = function (options, word, score) {
return word.match(/[A-Z]/) && score;
};
validation.wordOneNumber = function (options, word, score) {
return word.match(/\d+/) && score;
};
validation.wordThreeNumbers = function (options, word, score) {
return word.match(/(.*[0-9].*[0-9].*[0-9])/) && score;
};
validation.wordOneSpecialChar = function (options, word, score) {
return word.match(/[!,@,#,$,%,\^,&,*,?,_,~]/) && score;
};
validation.wordTwoSpecialChar = function (options, word, score) {
return word.match(/(.*[!,@,#,$,%,\^,&,*,?,_,~].*[!,@,#,$,%,\^,&,*,?,_,~])/) && score;
};
validation.wordUpperLowerCombo = function (options, word, score) {
return word.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/) && score;
};
validation.wordLetterNumberCombo = function (options, word, score) {
return word.match(/([a-zA-Z])/) && word.match(/([0-9])/) && score;
};
validation.wordLetterNumberCharCombo = function (options, word, score) {
return word.match(
/([a-zA-Z0-9].*[!,@,#,$,%,\^,&,*,?,_,~])|([!,@,#,$,%,\^,&,*,?,_,~].*[a-zA-Z0-9])/) &&
score;
};
rulesEngine.validation = validation;
rulesEngine.executeRules = function (options, word) {
var totalScore = 0;
$.each(options.rules.activated, function (rule, active) {
if (active) {
var score = options.rules.scores[rule],
funct = rulesEngine.validation[rule],
result,
errorMessage;
if (!$.isFunction(funct)) {
funct = options.rules.extra[rule];
}
if ($.isFunction(funct)) {
result = funct(options, word, score);
if (result) {
totalScore += result;
}
if (result < 0 || (!$.isNumeric(result) && !result)) {
errorMessage = options.ui.spanError(options, rule);
if (errorMessage.length > 0) {
options.instances.errors.push(errorMessage);
}
}
}
}
});
return totalScore;
};
}(jQuery, rulesEngine));
try {
if (module && module.exports) {
module.exports = rulesEngine;
}
} catch (ignore) {}
// Source: src/options.js
var defaultOptions = {};
defaultOptions.common = {};
defaultOptions.common.minChar = 6;
defaultOptions.common.usernameField = "#username";
defaultOptions.common.userInputs = [
// Selectors for input fields with user input
];
defaultOptions.common.onLoad = undefined;
defaultOptions.common.onKeyUp = undefined;
defaultOptions.common.zxcvbn = false;
defaultOptions.common.zxcvbnTerms = [
// List of disrecommended words
];
defaultOptions.common.debug = false;
defaultOptions.rules = {};
defaultOptions.rules.extra = {};
defaultOptions.rules.scores = {
wordNotEmail: -100,
wordLength: -50,
wordSimilarToUsername: -100,
wordSequences: -20,
wordTwoCharacterClasses: 2,
wordRepetitions: -25,
wordLowercase: 1,
wordUppercase: 3,
wordOneNumber: 3,
wordThreeNumbers: 5,
wordOneSpecialChar: 3,
wordTwoSpecialChar: 5,
wordUpperLowerCombo: 2,
wordLetterNumberCombo: 2,
wordLetterNumberCharCombo: 2
};
defaultOptions.rules.activated = {
wordNotEmail: true,
wordLength: true,
wordSimilarToUsername: true,
wordSequences: true,
wordTwoCharacterClasses: false,
wordRepetitions: false,
wordLowercase: true,
wordUppercase: true,
wordOneNumber: true,
wordThreeNumbers: true,
wordOneSpecialChar: true,
wordTwoSpecialChar: true,
wordUpperLowerCombo: true,
wordLetterNumberCombo: true,
wordLetterNumberCharCombo: true
};
defaultOptions.rules.raisePower = 1.4;
defaultOptions.ui = {};
defaultOptions.ui.bootstrap2 = false;
defaultOptions.ui.bootstrap4 = false;
defaultOptions.ui.colorClasses = ["danger", "warning", "success"];
defaultOptions.ui.showProgressBar = true;
defaultOptions.ui.showPopover = false;
defaultOptions.ui.popoverPlacement = "bottom";
defaultOptions.ui.showStatus = false;
defaultOptions.ui.spanError = function (options, key) {
"use strict";
var text = options.ui.errorMessages[key];
if (!text) {
return '';
}
return '<span style="color: #d52929">' + text + '</span>';
};
defaultOptions.ui.popoverError = function (errors) {
"use strict";
var message = "<div>Errors:<ul class='error-list' style='margin-bottom: 0;'>";
jQuery.each(errors, function (idx, err) {
message += "<li>" + err + "</li>";
});
message += "</ul></div>";
return message;
};
defaultOptions.ui.errorMessages = {
wordLength: "Your password is too short",
wordNotEmail: "Do not use your email as your password",
wordSimilarToUsername: "Your password cannot contain your username",
wordTwoCharacterClasses: "Use different character classes",
wordRepetitions: "Too many repetitions",
wordSequences: "Your password contains sequences"
};
defaultOptions.ui.verdicts = ["Weak", "Normal", "Medium", "Strong", "Very Strong"];
defaultOptions.ui.showVerdicts = true;
defaultOptions.ui.showVerdictsInsideProgressBar = false;
defaultOptions.ui.useVerdictCssClass = false;
defaultOptions.ui.showErrors = false;
defaultOptions.ui.container = undefined;
defaultOptions.ui.viewports = {
progress: undefined,
verdict: undefined,
errors: undefined
};
defaultOptions.ui.scores = [14, 26, 38, 50];
// Source: src/ui.js
var ui = {};
(function ($, ui) {
"use strict";
var statusClasses = ["error", "warning", "success"];
ui.getContainer = function (options, $el) {
var $container;
$container = $(options.ui.container);
if (!($container && $container.length === 1)) {
$container = $el.parent();
}
return $container;
};
ui.findElement = function ($container, viewport, cssSelector) {
if (viewport) {
return $container.find(viewport).find(cssSelector);
}
return $container.find(cssSelector);
};
ui.getUIElements = function (options, $el) {
var $container, selector, result;
if (options.instances.viewports) {
return options.instances.viewports;
}
$container = ui.getContainer(options, $el);
result = {};
if (options.ui.bootstrap4) {
selector = "progress.progress";
} else {
selector = "div.progress";
}
result.$progressbar = ui.findElement($container, options.ui.viewports.progress,
selector);
if (options.ui.showVerdictsInsideProgressBar) {
result.$verdict = result.$progressbar.find("span.password-verdict");
}
if (!options.ui.showPopover) {
if (!options.ui.showVerdictsInsideProgressBar) {
result.$verdict = ui.findElement($container, options.ui.viewports.verdict,
"span.password-verdict");
}
result.$errors = ui.findElement($container, options.ui.viewports.errors,
"ul.error-list");
}
options.instances.viewports = result;
return result;
};
ui.initProgressBar = function (options, $el) {
var $container = ui.getContainer(options, $el),
progressbar = "<div class='progress'><div class='"; // Boostrap 2
if (!options.ui.bootstrap2 && !options.ui.bootstrap4) {
// Bootstrap 3
progressbar += "progress-";
}
progressbar += "bar'>";
if (options.ui.bootstrap4) {
// Boostrap 4
progressbar = "<progress class='progress' value='0' max='100'>";
}
if (options.ui.showVerdictsInsideProgressBar) {
progressbar += "<span class='password-verdict'></span>";
}
if (options.ui.bootstrap4) {
progressbar += "</progress>";
} else {
progressbar += "</div></div>";
}
if (options.ui.viewports.progress) {
$container.find(options.ui.viewports.progress).append(progressbar);
} else {
$(progressbar).insertAfter($el);
}
};
ui.initHelper = function (options, $el, html, viewport) {
var $container = ui.getContainer(options, $el);
if (viewport) {
$container.find(viewport).append(html);
} else {
$(html).insertAfter($el);
}
};
ui.initVerdict = function (options, $el) {
ui.initHelper(options, $el, "<span class='password-verdict'></span>",
options.ui.viewports.verdict);
};
ui.initErrorList = function (options, $el) {
ui.initHelper(options, $el, "<ul class='error-list'></ul>",
options.ui.viewports.errors);
};
ui.initPopover = function (options, $el) {
$el.popover("destroy");
$el.popover({
html: true,
placement: options.ui.popoverPlacement,
trigger: "manual",
content: " "
});
};
ui.initUI = function (options, $el) {
if (options.ui.showPopover) {
ui.initPopover(options, $el);
} else {
if (options.ui.showErrors) {
ui.initErrorList(options, $el);
}
if (options.ui.showVerdicts && !options.ui.showVerdictsInsideProgressBar) {
ui.initVerdict(options, $el);
}
}
if (options.ui.showProgressBar) {
ui.initProgressBar(options, $el);
}
};
ui.updateProgressBar = function (options, $el, cssClass, percentage) {
var $progressbar = ui.getUIElements(options, $el).$progressbar,
$bar = $progressbar.find(".progress-bar"),
cssPrefix = "progress-";
if (options.ui.bootstrap2) {
$bar = $progressbar.find(".bar");
cssPrefix = "";
}
$.each(options.ui.colorClasses, function (idx, value) {
if (options.ui.bootstrap4) {
$progressbar.removeClass(cssPrefix + value);
} else {
$bar.removeClass(cssPrefix + "bar-" + value);
}
});
if (options.ui.bootstrap4) {
$progressbar.addClass(cssPrefix + options.ui.colorClasses[cssClass]);
$progressbar.val(percentage);
} else {
$bar.addClass(cssPrefix + "bar-" + options.ui.colorClasses[cssClass]);
$bar.css("width", percentage + '%');
}
};
ui.updateVerdict = function (options, $el, cssClass, text) {
var $verdict = ui.getUIElements(options, $el).$verdict;
$verdict.removeClass(options.ui.colorClasses.join(' '));
if (cssClass > -1) {
$verdict.addClass(options.ui.colorClasses[cssClass]);
}
$verdict.html(text);
};
ui.updateErrors = function (options, $el) {
var $errors = ui.getUIElements(options, $el).$errors,
html = "";
$.each(options.instances.errors, function (idx, err) {
html += "<li>" + err + "</li>";
});
$errors.html(html);
};
ui.updatePopover = function (options, $el, verdictText) {
var popover = $el.data("bs.popover"),
html = "",
hide = true;
if (options.ui.showVerdicts &&
!options.ui.showVerdictsInsideProgressBar &&
verdictText.length > 0) {
html = "<h5><span class='password-verdict'>" + verdictText +
"</span></h5>";
hide = false;
}
if (options.ui.showErrors) {
if (options.instances.errors.length > 0) {
hide = false;
}
html += options.ui.popoverError(options.instances.errors);
}
if (hide) {
$el.popover("hide");
return;
}
if (options.ui.bootstrap2) {
popover = $el.data("popover");
}
if (popover.$arrow && popover.$arrow.parents("body").length > 0) {
$el.find("+ .popover .popover-content").html(html);
} else {
// It's hidden
popover.options.content = html;
$el.popover("show");
}
};
ui.updateFieldStatus = function (options, $el, cssClass) {
var targetClass = options.ui.bootstrap2 ? ".control-group" : ".form-group",
$container = $el.parents(targetClass).first();
$.each(statusClasses, function (idx, css) {
if (!options.ui.bootstrap2) {
css = "has-" + css;
}
$container.removeClass(css);
});
cssClass = statusClasses[cssClass];
if (!options.ui.bootstrap2) {
cssClass = "has-" + cssClass;
}
$container.addClass(cssClass);
};
ui.percentage = function (score, maximun) {
var result = Math.floor(100 * score / maximun);
result = result <= 0 ? 1 : result; // Don't show the progress bar empty
result = result > 100 ? 100 : result;
return result;
};
ui.getVerdictAndCssClass = function (options, score) {
var cssClass, verdictText, level;
if (score <= 0) {
cssClass = 0;
level = -1;
verdictText = options.ui.verdicts[0];
} else if (score < options.ui.scores[0]) {
cssClass = 0;
level = 0;
verdictText = options.ui.verdicts[0];
} else if (score < options.ui.scores[1]) {
cssClass = 0;
level = 1;
verdictText = options.ui.verdicts[1];
} else if (score < options.ui.scores[2]) {
cssClass = 1;
level = 2;
verdictText = options.ui.verdicts[2];
} else if (score < options.ui.scores[3]) {
cssClass = 1;
level = 3;
verdictText = options.ui.verdicts[3];
} else {
cssClass = 2;
level = 4;
verdictText = options.ui.verdicts[4];
}
return [verdictText, cssClass, level];
};
ui.updateUI = function (options, $el, score) {
var cssClass, barPercentage, verdictText, verdictCssClass;
cssClass = ui.getVerdictAndCssClass(options, score);
verdictText = score === 0 ? '' : cssClass[0];
cssClass = cssClass[1];
verdictCssClass = options.ui.useVerdictCssClass ? cssClass : -1;
if (options.ui.showProgressBar) {
barPercentage = ui.percentage(score, options.ui.scores[3]);
ui.updateProgressBar(options, $el, cssClass, barPercentage);
if (options.ui.showVerdictsInsideProgressBar) {
ui.updateVerdict(options, $el, verdictCssClass, verdictText);
}
}
if (options.ui.showStatus) {
ui.updateFieldStatus(options, $el, cssClass);
}
if (options.ui.showPopover) {
ui.updatePopover(options, $el, verdictText);
} else {
if (options.ui.showVerdicts && !options.ui.showVerdictsInsideProgressBar) {
ui.updateVerdict(options, $el, verdictCssClass, verdictText);
}
if (options.ui.showErrors) {
ui.updateErrors(options, $el);
}
}
};
}(jQuery, ui));
// Source: src/methods.js
var methods = {};
(function ($, methods) {
"use strict";
var onKeyUp, applyToAll;
onKeyUp = function (event) {
var $el = $(event.target),
options = $el.data("pwstrength-bootstrap"),
word = $el.val(),
userInputs,
verdictText,
verdictLevel,
score;
if (options === undefined) {
return;
}
options.instances.errors = [];
if (word.length === 0) {
score = 0;
} else {
if (options.common.zxcvbn) {
userInputs = [];
$.each(options.common.userInputs.concat([options.common.usernameField]), function (
idx, selector) {
var value = $(selector).val();
if (value) {
userInputs.push(value);
}
});
userInputs = userInputs.concat(options.common.zxcvbnTerms);
score = Math.log2(zxcvbn(word, userInputs).guesses);
} else {
score = rulesEngine.executeRules(options, word);
}
}
ui.updateUI(options, $el, score);
verdictText = ui.getVerdictAndCssClass(options, score);
verdictLevel = verdictText[2];
verdictText = verdictText[0];
if (options.common.debug) {
console.log(score + ' - ' + verdictText);
}
if ($.isFunction(options.common.onKeyUp)) {
options.common.onKeyUp(event, {
score: score,
verdictText: verdictText,
verdictLevel: verdictLevel
});
}
};
methods.init = function (settings) {
this.each(function (idx, el) {
// Make it deep extend (first param) so it extends too the
// rules and other inside objects
var clonedDefaults = $.extend(true, {}, defaultOptions),
localOptions = $.extend(true, clonedDefaults, settings),
$el = $(el);
localOptions.instances = {};
$el.data("pwstrength-bootstrap", localOptions);
$el.on("keyup", onKeyUp);
$el.on("change", onKeyUp);
$el.on("paste", onKeyUp);
ui.initUI(localOptions, $el);
if ($.trim($el.val())) { // Not empty, calculate the strength
$el.trigger("keyup");
}
if ($.isFunction(localOptions.common.onLoad)) {
localOptions.common.onLoad();
}
});
return this;
};
methods.destroy = function () {
this.each(function (idx, el) {
var $el = $(el),
options = $el.data("pwstrength-bootstrap"),
elements = ui.getUIElements(options, $el);
elements.$progressbar.remove();
elements.$verdict.remove();
elements.$errors.remove();
$el.removeData("pwstrength-bootstrap");
});
};
methods.forceUpdate = function () {
this.each(function (idx, el) {
var event = {
target: el
};
onKeyUp(event);
});
};
methods.addRule = function (name, method, score, active) {
this.each(function (idx, el) {
var options = $(el).data("pwstrength-bootstrap");
options.rules.activated[name] = active;
options.rules.scores[name] = score;
options.rules.extra[name] = method;
});
};
applyToAll = function (rule, prop, value) {
this.each(function (idx, el) {
$(el).data("pwstrength-bootstrap").rules[prop][rule] = value;
});
};
methods.changeScore = function (rule, score) {
applyToAll.call(this, rule, "scores", score);
};
methods.ruleActive = function (rule, active) {
applyToAll.call(this, rule, "activated", active);
};
$.fn.pwstrength = function (method) {
var result;
if (methods[method]) {
result = methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === "object" || !method) {
result = methods.init.apply(this, arguments);
} else {
$.error("Method " + method + " does not exist on jQuery.pwstrength-bootstrap");
}
return result;
};
}(jQuery, methods));
}(jQuery));
+89
View File
@@ -0,0 +1,89 @@
Package.describe({
name: 'clinical:active-entry',
version: '1.5.16',
summary: 'SignIn, SignUp, and ForgotPassword pages for Clinical Framework.',
git: 'https://github.com/clinical-meteor/clinical-active-entry',
documentation: 'README.md'
});
Package.onUse(function (api) {
api.versionsFrom('1.1.0.3');
api.use([
'meteor-platform',
'templating',
'clinical:router@2.0.19',
'grove:less@0.1.1',
'session',
'reactive-dict'
//'codetheweb:zxcvbn'
], ['client']);
api.use([
'accounts-base',
'accounts-password'
]);
api.use([
'zuuk:stale-session@1.0.8',
'random'
], ['client', 'server']);
api.addFiles([
'lib/ActiveEntry.js',
'lib/Accounts.js'
]);
api.addFiles([
'lib/jquery.pwstrength.bootstrap.js',
'lib/checkPasswordStrength.js',
'lib/hashCodeGenerator.js'
], ['client']);
api.imply('accounts-base');
api.imply('accounts-password');
api.addFiles([
'components/entryPages.js',
'components/entryPages.less',
'components/entrySignIn/entrySignIn.html',
'components/entrySignIn/entrySignIn.js',
'components/entrySignIn/entrySignIn.less',
'components/entrySignUp/entrySignUp.html',
'components/entrySignUp/entrySignUp.js',
'components/entrySignUp/entrySignUp.less',
'components/forgotPassword/forgotPassword.html',
'components/forgotPassword/forgotPassword.js',
'components/forgotPassword/forgotPassword.less',
'components/changePassword/changePassword.html',
'components/changePassword/changePassword.js',
'components/changePassword/changePassword.less',
'components/resetPassword/resetPassword.html',
'components/resetPassword/resetPassword.js'
], ['client']);
api.addFiles('server/methods.js', "server", {testOnly: true});
api.export("ActiveEntry");
});
Package.onTest(function (api) {
api.use([
'templating',
'clinical:router@2.0.19',
'grove:less@0.1.1',
'standard-app-packages'
], ['client']);
api.use('tinytest');
api.use('clinical:active-entry');
api.use('clinical:verification');
api.addFiles('tests/gagarin/activeEntryTests.js');
});
@@ -0,0 +1,202 @@
Meteor.methods({
initializeEntryUsers: function (){
console.log('Initializing Users', Meteor.users.find().fetch());
},
dropEntryUsers: function (){
console.log('Drop Users', Meteor.users.find().fetch());
Meteor.users.find().forEach(function(user){
Meteor.users.remove({_id: user._id});
});
},
insertHashedPassword: function(passwordParameters) {
var hashedPassword = passwordParameters[0];
var passwordHistoryCount = passwordParameters[1];
var userId = Meteor.userId();
var previousPasswords = Meteor.users.findOne({_id: userId}).previousPasswords;
if (previousPasswords) {
if (previousPasswords.length == passwordHistoryCount) {
// Remove oldest password
var ascSortedPasswords = _.sortBy(previousPasswords, function(previousPassword){ return previousPassword.createdAt; });
ascSortedPasswords.splice(0, 1);
previousPasswords = ascSortedPasswords;
}
previousPasswords.push({hashedPassword: hashedPassword, createdAt: new Date()});
Meteor.users.update({_id: userId}, {$set: {previousPasswords: previousPasswords}});
} else {
Meteor.users.update({_id: userId}, {$set: {previousPasswords: [{hashedPassword: hashedPassword, createdAt: new Date(), select: false}]}});
}
},
checkPasswordExistence: function(hashedPassword) {
var previousPasswords = Meteor.users.find({_id: Meteor.userId()}).fetch()[0].previousPasswords;
for(var i=0; i< previousPasswords.length; i++) {
var recordedHashedPassword = previousPasswords[i].hashedPassword;
if (recordedHashedPassword == hashedPassword) {
return true;
}
}
return false;
},
getFailedAttemptsCount: function(emailAddress) {
// Check if the user actually exists, and if not, stop here
var currentUser = Meteor.users.findOne({"emails.address": emailAddress});
if (!currentUser) {
return;
}
return currentUser.failedPasswordAttempts || 0;
},
updateFailedAttempts: function(emailAddress, failedAttemptsLimit) {
// Check if the user actually exists, and if not, stop here
var currentUser = Meteor.users.findOne({"emails.address": emailAddress});
if (!currentUser) {
return;
}
var failedAttemptCount = currentUser.failedPasswordAttempts || 0;
if (failedAttemptCount == failedAttemptsLimit) {
return failedAttemptCount;
} else {
if (failedAttemptCount == (failedAttemptsLimit - 1)) {
// Locked user account
Meteor.users.update({"emails.address": emailAddress}, {$set: {"profile.isLocked": true, failedPasswordAttempts: failedAttemptCount + 1}});
} else if (failedAttemptCount < (failedAttemptsLimit - 1)) {
Meteor.users.update({"emails.address": emailAddress}, {$set: {failedPasswordAttempts: failedAttemptCount + 1}});
}
}
return failedAttemptCount + 1;
},
lockAccount: function(emailAddress) {
// Check if the user actually exists, and if not, stop here
var currentUser = Meteor.users.findOne({"emails.address": emailAddress});
if (!currentUser) {
return;
}
Meteor.users.update({"emails.address": emailAddress}, {$set: {"profile.isLocked": true}});
},
resetFailedAttempts: function(emailAddress) {
Meteor.users.update({"emails.address": emailAddress}, {$set: {failedPasswordAttempts: 0}});
},
updatePasswordSetDate: function() {
Meteor.users.update({_id: Meteor.userId()}, {$set: {"services.password.setDate": new Date()}});
},
isPasswordExpired: function(passwordExpirationDays) {
var passwordSetDate = Meteor.users.find({_id: Meteor.userId()}).fetch()[0].services.password.setDate;
if (!passwordSetDate) {
return false;
}
passwordSetDate.setDate(passwordSetDate.getDate() + passwordExpirationDays);
if (passwordSetDate <= new Date()) {
return true;
}
return false;
},
isAccountLocked: function(emailAddress) {
// Check if the user actually exists, and if not, stop here
var currentUser = Meteor.users.findOne({"emails.address": emailAddress});
if (!currentUser) {
return;
}
return currentUser.profile.isLocked || false;
},
updateLastLoginDate: function () {
var user = Meteor.users.findOne(Meteor.userId());
if (!user) {
return;
}
var priorLoginDate = user.lastLoginDate;
if (!priorLoginDate) {
priorLoginDate = new Date();
}
// Update priorLoginDate and lastLoginDate
Meteor.users.update({_id: Meteor.userId()}, {$set: {priorLoginDate: priorLoginDate, lastLoginDate: new Date()}});
},
isAccountInactive: function (emailAddress, inactivityPeriodDays) {
// Check if the user actually exists, and if not, stop here
var currentUser = Meteor.users.findOne({"emails.address": emailAddress});
if (!currentUser) {
return;
}
var lastLoginDate = currentUser.lastLoginDate;
if (!lastLoginDate) {
return false;
}
lastLoginDate.setDate(lastLoginDate.getDate() + inactivityPeriodDays);
if (lastLoginDate <= new Date()) {
return true;
}
return false;
},
isLDAPSet: function() {
if (LDAP_DEFAULTS && LDAP_DEFAULTS.url && LDAP_DEFAULTS.port) {
return true;
}
return false;
},
checkResetTokenIsExpired: function(token, expireTimeInMinute) {
var user = Meteor.users.findOne({"services.password.reset.token": token});
if (!user) {
return;
}
var tokenCreatedTime = user.services.password.reset.when;
if (!tokenCreatedTime) {
return;
}
// Token will be expired if created time is over 30 min as default
tokenCreatedTime.setTime(tokenCreatedTime.getTime() + expireTimeInMinute*60000);
if (tokenCreatedTime < new Date()) {
// Remove reset token
Meteor.users.update({_id: user._id}, {$unset: {'services.password.reset': 1}});
return true;
}
return false;
},
checkResetPasswordExistence: function(hashedPassword, token) {
var user = Meteor.users.findOne({"services.password.reset.token": token});
if (!user) {
return;
}
var previousPasswords = user.previousPasswords;
if (!previousPasswords) {
return;
}
for(var i=0; i< previousPasswords.length; i++) {
var recordedHashedPassword = previousPasswords[i].hashedPassword;
if (recordedHashedPassword == hashedPassword) {
return true;
}
}
return false;
},
});
@@ -0,0 +1,215 @@
// var nightwatch = require('nightwatch');
describe('clinical:active-entry', function () {
var server = meteor();
var client = browser(server);
// before(function () {
// return server.promise(function (resolve){
// Meteor.users.find().forEach(function(user){
// Meteor.users.remove({_id: user._id});
// }, function(){
// resolve();
// });
// });
// });
// afterEach(function (){
// return client.promise(function (resolve){
// Meteor.logout(function(error, result){
// resolve();
// });
// });
// });
it("ActiveEntry object should be loaded on client and server", function () {
return server.execute(function () {
expect(ActiveEntry.isAbc()).to.equal('abc');
}).then(function (data){
return client.execute(function (a) {
expect(ActiveEntry.isAbc()).to.equal('abc');
});
});
});
it("Error messages should be empty by default", function () {
return client.execute(function () {
expect(ActiveEntry.errorMessages.get('signInError')).to.equal(false);
});
});
// ActiveEntry.verifyEmail
it('Email validation confirms it is a properly formatted email.', function () {
return client.execute(function (a) {
ActiveEntry.verifyEmail('janedoe@somewhere.com');
expect(ActiveEntry.successMessages.get('email')).to.equal("Email present");
ActiveEntry.verifyEmail('');
expect(ActiveEntry.errorMessages.get('email')).to.equal("Email is required");
ActiveEntry.verifyEmail('janedoe.somewhere.com');
expect(ActiveEntry.errorMessages.get('email')).to.equal("Email is poorly formatted");
});
});
// ActiveEntry.verifyPassword
it('Password validation confirms it is a properly formatted password.', function () {
return client.execute(function (a) {
ActiveEntry.verifyPassword('');
expect(ActiveEntry.errorMessages.get('password')).to.equal("Password is required");
ActiveEntry.verifyPassword('kittens');
expect(ActiveEntry.errorMessages.get('password')).to.equal(Session.get('passwordWarning'));
ActiveEntry.verifyPassword('K1tt#ns123');
expect(ActiveEntry.successMessages.get('password')).to.equal("Password present");
});
});
// ActiveEntry.verifyConfirmPassword
it('Password match confirms that two passwords are the same.', function () {
return client.execute(function (a) {
ActiveEntry.verifyConfirmPassword('K1tt#kittens', 'kittens');
expect(ActiveEntry.errorMessages.get('confirm')).to.equal("Passwords do not match");
ActiveEntry.verifyConfirmPassword('kittens123', 'kittens');
expect(ActiveEntry.errorMessages.get('confirm')).to.equal("Passwords do not match");
ActiveEntry.verifyConfirmPassword('kittens123', 'kittens123');
expect(ActiveEntry.errorMessages.get('confirm')).to.equal("Passwords match");
ActiveEntry.verifyConfirmPassword('K1tt#ns123', 'K1tt#ns123');
expect(ActiveEntry.successMessages.get('confirm')).to.equal("Passwords match");
});
});
// ActiveEntry.verifyFullName
it('Fullname validation confirms that at least a first and last name are entered.', function () {
return client.execute(function (a) {
ActiveEntry.verifyFullName('');
expect(ActiveEntry.errorMessages.get('fullName')).to.equal("Name is required");
ActiveEntry.verifyFullName('Jane');
expect(ActiveEntry.errorMessages.get('fullName')).to.equal("Name is probably not complete");
ActiveEntry.verifyFullName('Jane Doe');
expect(ActiveEntry.successMessages.get('fullName')).to.equal("Name present");
});
});
// // ActiveEntry.signIn
// it('Newly created user record should have role, profile, and name set.', function () {
// return client.execute(function () {
// ActiveEntry.signUp('janedoe@test.org', 'Janed*e123', 'Janed*e123', 'Jane Doe');
// expect(ActiveEntry.successMessages.get('fullName')).to.equal("Name present");
// }).then(function (){
// return server.wait(500, 'until account is created on the server', function () {
// return Meteor.users.findOne({'emails.address': 'janedoe@test.org'});
// }).then(function (user){
// expect(user.role).to.equal('user');
// expect(user.profile.fullName).to.equal('Jane Doe');
// });
// });
// });
// ActiveEntry.signIn
it('Newly created user record should have role, profile, and name set.', function () {
return client.execute(function () {
// ActiveEntry.signUp('janedoe@test.org', 'Janed*e123', 'Janed*e123', 'Jane Doe');
ActiveEntry.signUp('janedoe@test.org', 'Janedoe123', 'Janedoe123', 'Jane Doe');
expect(ActiveEntry.successMessages.get('fullName')).to.equal("Name present");
}).then(function (){
return server.wait(500, 'until account is created on the server', function () {
return Meteor.users.findOne({'emails.address': 'janedoe@test.org'});
}).then(function (user){
expect(user.role).to.equal('user');
expect(user.profile.fullName).to.equal('Jane Doe');
});
});
});
it("Newly created user should have fullName(), preferredName(), and familyName() methods.", function () {
return server.execute(function () {
var user = Meteor.users.findOne({'emails.address': 'janedoe@test.org'});
expect(user).to.be.ok;
expect(user.fullName()).to.equal('Jane Doe');
expect(user.givenName()).to.equal('Jane');
expect(user.familyName()).to.equal('Doe');
}).then(function (){
// client.wait(500, "until user is logged out", function(){
// Meteor.logout();
// });
return client.promise(function (resolve){
Meteor.logout(function (error, result){
resolve();
});
});
});
});
it("Newly created user can sign in to the application.", function () {
return client.execute(function () {
expect(Meteor.userId()).to.not.exist;
ActiveEntry.signIn('janedoe@test.org', 'Janed*e123');
}).then(function (){
client.wait(3000, "for user to sign in", function (){
expect(Meteor.userId()).to.exist;
});
});
});
it("Newly created user can sign out of the application.", function () {
return client.execute(function () {
expect(Meteor.userId()).to.not.exist;
ActiveEntry.signIn('janedoe@test.org', 'Janed*e123');
}).then(function (){
client.wait(3000, "for user to sign in", function (){
expect(Meteor.userId()).to.exist;
ActiveEntry.signOut('janedoe@test.org');
}).then(function (){
expect(Meteor.userId()).to.not.exist;
});
});
});
// it("config should be able to change company logo", function () {
//
// });
// it("config should be able to change entry message text", function () {
//
// });
// it("new user should be able to register on desktop", function () {
// client.location = "/sign-in";
//
// client.execute(function () {
// expect($('#entrySignIn')).to.exist();
// expect($('#signInPageEmailInput')).to.exist();
// expect($('#signInPagePasswordInput')).to.exist();
// expect($('#signInToAppButton')).to.exist();
// }).setValue('#signInPageEmailInput', 'house@test.org')
// .setValue('#signInPagePasswordInput', 'house@test.org')
// .click('#signInToAppButton').execute(function(){
// expect($('#entrySignIn')).to.exist();
// expect($('#signInPageEmailInput')).to.exist();
// expect($('#signInPagePasswordInput')).to.exist();
// expect($('#signInToAppButton')).to.exist();
// // expect($('#entrySignIn')).to.not.exist();
// // expect($('#signInPageEmailInput')).to.not.exist();
// // expect($('#signInPagePasswordInput')).to.not.exist();
// // expect($('#signInToAppButton')).to.not.exist();
// });
// // .then(function(data){
// // return server.execute(3000, 'until the account is created', function () {
// // expect(Meteor.users.find().count()).to.be.above(20);
// // });
// // });
// });
});
@@ -0,0 +1,22 @@
// async version calls method on the server
exports.command = function () {
var client = this;
this
.timeoutsAsyncScript(5000)
.executeAsync(function (data, meteorCallback) {
//return HipaaLogger.logEventObject(data);
Meteor.call("dropCollaborations", data, function (meteorError, meteorResult) {
var response = (meteorError ? {
error: meteorError
} : {
result: meteorResult
});
meteorCallback(response);
});
}, [], function (result) {
console.log("result.value", result.value);
client.assert.ok(result.value);
}).pause(1000);
return this;
};
@@ -0,0 +1,222 @@
// when new user fills out form and registers, new user should get created
// when user signs in with username and password, should redirect to home page
// newly created user record should have role
// newly created user record should have profile
// newly created user record should have full, preferred, and family name
// user object should return first name
// user object should return last name
// user should be able to request reset password email
// user should be able to request be able to create new account
// guest should be notified if username already exists
// guest should be notified if passwords do not match
// guest should be notified if email is not correctly formatted
// new user should be able to register on desktop
// new user should be able to register on tablet
// existing user should be able to sign in on desktop
// existing user should be able to sign in on tablet
// existing user should be able to sign in on phone
// existing user should be able to change their password
// company logo should display on sign//in page
module.exports = {
tags: ['users', 'entry'],
before: function (client) {
client
.url("http://localhost:3000/entrySignUp")
.initializeUsers()
.resizeWindow(1600, 1200);
},
"new user should be able to register on desktop": function (client) {
client
.verify.elementPresent("#entrySignUp")
.verify.elementPresent("#signUpPageTitle")
.verify.elementPresent("#signUpPageMessage")
.verify.elementPresent("#signUpPageEmailInput")
.verify.elementPresent("#signUpPagePasswordInput")
.verify.elementPresent("#signUpPageJoinNowButton")
.verify.elementPresent("#signUpPageSignInButton");
},
"company logo should display on sign-in page": function (client) {
client
.verify.elementPresent("#entrySignUp")
.verify.elementPresent("#entryAppLogo");
},
"user should be able to request be able to create new account": function (client) {
client.verify.elementPresent("#signUpPageEmailInput")
.verify.elementPresent("#signUpPagePasswordInput")
.verify.elementPresent("#signUpPagePasswordInput")
.verify.elementPresent("#signUpPageJoinNowButton");
},
"guest should be notified if password is insecure": function (client) {
client
.clearValue("input")
.verify.elementPresent("#signUpPagePasswordInput")
.verify.cssProperty('#signUpPagePasswordInput', 'border', '1px solid gray')
.setValue("#signUpPagePasswordInput", "jan")
.verify.cssProperty('#signUpPagePasswordInput', 'border', '1px solid rgb(242, 222, 222)')
.setValue("#signUpPagePasswordInput", "iceD*e123")
.verify.cssProperty('#signUpPagePasswordInput', 'border', '1px solid green')
.verify.cssProperty('#signUpPagePasswordConfirmInput', 'border', '1px solid gray')
.setValue("#signUpPagePasswordConfirmInput", "ja")
.verify.cssProperty('#signUpPagePasswordConfirmInput', 'border',
'1px solid rgb(242, 222, 222)')
.clearValue("#signUpPagePasswordConfirmInput")
.setValue("#signUpPagePasswordConfirmInput", "Janiced*e123")
.verify.cssProperty('#signUpPagePasswordConfirmInput', 'border', '1px solid green');
},
"guest should be notified if passwords do not match": function (client) {
client
.clearValue("#signUpPagePasswordConfirmInput")
.clearValue("#signUpPagePasswordInput")
.resetEntry()
.pause(500)
.verify.cssProperty('#signUpPagePasswordInput', 'border', '1px solid gray')
.verify.cssProperty('#signUpPagePasswordConfirmInput', 'border', '1px solid gray')
.setValue("#signUpPagePasswordInput", "Janiced*e123")
.verify.cssProperty('#signUpPagePasswordInput', 'border', '1px solid green')
.verify.cssProperty('#signUpPagePasswordConfirmInput', 'border', '1px solid gray')
.setValue("#signUpPagePasswordConfirmInput", "Janiced*e123")
.verify.cssProperty('#signUpPagePasswordInput', 'border', '1px solid green')
.verify.cssProperty('#signUpPagePasswordConfirmInput', 'border', '1px solid green');
},
"guest should be notified if email is not correctly formatted": function (client) {
client
.clearValue("#signUpPageEmailInput")
.resetEntry()
.verify.elementPresent("#signUpPageEmailInput")
.verify.cssProperty('#signUpPageEmailInput', 'border', '1px solid gray')
.setValue("#signUpPageEmailInput", "janicedoe")
.verify.cssProperty('#signUpPageEmailInput', 'border', '1px solid rgb(242, 222, 222)')
.setValue("#signUpPageEmailInput", "@symptomatic.io")
.verify.cssProperty('#signUpPageEmailInput', 'border', '1px solid green');
},
"when new user fills out form and registers, new user should get created": function (client) {
client
.verify.elementPresent("#entrySignUp")
.clearValue("#signUpPagePasswordConfirmInput")
.clearValue("#signUpPagePasswordInput")
.clearValue("#signUpPageFullNameInput")
.clearValue("#signUpPageEmailInput")
.resetEntry()
.setValue("#signUpPageFullNameInput", "Janice Doe")
.setValue("#signUpPageEmailInput", "janicedoe@symptomatic.io")
.setValue("#signUpPagePasswordInput", "Janiced*e123")
.setValue("#signUpPagePasswordConfirmInput", "Janiced*e123")
.click("#signUpPageJoinNowButton").pause(1000)
.verify.containsText("#usernameLink", "janicedoe@symptomatic.io");
},
"user should be able to signout": function (client) {
client
.verify.elementPresent("#logoutButton")
.click("#logoutButton").pause(300)
.verify.containsText("#usernameLink", "Sign In");
},
"user should be able to request reset password email": function (client) {
client
.url("http://localhost:3000/entrySignIn")
.verify.elementPresent("#forgotPasswordButton")
.click("#forgotPasswordButton")
.verify.elementPresent("#forgotPassword")
.verify.elementPresent("#signInPageEmailInput")
.verify.elementPresent("#sendReminderButton");
},
"existing user should be able to sign in on desktop": function (client) {
client
.url("http://localhost:3000/entrySignIn")
.resizeWindow(1600, 1200)
.verify.containsText("#usernameLink", "Sign In")
.signIn("janicedoe@symptomatic.io", "Janiced*e123").pause(500)
.verify.containsText("#usernameLink", "janicedoe@symptomatic.io")
.click("#logoutButton").pause(200)
.verify.containsText("#usernameLink", "Sign In");
},
"existing user should be able to sign in on tablet": function (client) {
client
.url("http://localhost:3000/entrySignIn")
.resizeWindow(1024, 768)
.verify.containsText("#usernameLink", "Sign In")
.signIn("janicedoe@symptomatic.io", "Janiced*e123").pause(500)
.verify.containsText("#usernameLink", "janicedoe@symptomatic.io")
.click("#logoutButton").pause(200)
.verify.containsText("#usernameLink", "Sign In");
},
"existing user should be able to sign in on phone": function (client) {
client
.url("http://localhost:3000/entrySignIn")
.resizeWindow(320, 960)
// .verify.containsText("#usernameLink", "Sign In")
.signIn("janicedoe@symptomatic.io", "Janiced*e123").pause(500)
.click("#navbarHeader").pause(300)
.verify.containsText("#usernameLink", "janicedoe@symptomatic.io")
.click("#logoutButton").pause(200)
.verify.containsText("#usernameLink", "Sign In");
},
"existing user should be able to change their password" : function (client) {
client
.url("http://localhost:3000/entrySignIn")
.resizeWindow(1600, 1200)
.verify.containsText("#usernameLink", "Sign In")
.signIn("janicedoe@symptomatic.io", "janicedoe123").pause(500)
.verify.containsText("#usernameLink", "janicedoe@symptomatic.io")
.url("http://localhost:3000/changePassword")
.verify.elementPresent("#changePasswordPageOldPasswordInput")
.verify.elementPresent("#changePasswordPagePasswordInput")
.verify.elementPresent("#changePasswordPagePasswordConfirmInput")
.verify.elementPresent("#changePasswordButton")
},
"existing user should be notified if desired new password is insecure" : function (client) {
client
.url("http://localhost:3000/entrySignIn")
.resizeWindow(1600, 1200)
.verify.containsText("#usernameLink", "Sign In")
.signIn("janicedoe@symptomatic.io", "janicedoe123").pause(500)
.verify.containsText("#usernameLink", "janicedoe@symptomatic.io")
.url("http://localhost:3000/changePassword")
.verify.elementPresent("#changePasswordPageOldPasswordInput")
.verify.elementPresent("#changePasswordPagePasswordInput")
.verify.elementPresent("#changePasswordPagePasswordConfirmInput")
.verify.elementPresent("#changePasswordButton")
.verify.cssProperty('#changePasswordPagePasswordInput', 'border', '1px solid gray')
.setValue("#changePasswordPagePasswordInput", "jan")
.verify.cssProperty('#changePasswordPagePasswordInput', 'border', '1px solid rgb(242, 222, 222)')
.setValue("#changePasswordPagePasswordInput", "icedoe123")
.verify.cssProperty('#changePasswordPagePasswordInput', 'border', '1px solid green')
.verify.cssProperty('#changePasswordPagePasswordConfirmInput', 'border', '1px solid gray')
.setValue("#changePasswordPagePasswordConfirmInput", "ja")
.verify.cssProperty('#changePasswordPagePasswordConfirmInput', 'border', '1px solid rgb(242, 222, 222)')
.clearValue("#changePasswordPagePasswordConfirmInput")
.setValue("#changePasswordPagePasswordConfirmInput", "janicedoe123")
.verify.cssProperty('#changePasswordPagePasswordConfirmInput', 'border', '1px solid green')
},
"if anonymous user tries to log in with non-existing account, a message is shown" : function (client) {
client
.url("http://localhost:3000/entrySignIn")
.resizeWindow(1024, 768)
.signIn("alice@symptomatic.io", "alice123").pause(500)
.verify.containsText("#signInPageMessage", "User not found [403]")
.verify.cssProperty("#signInPageMessage", "color", "rgba(169, 68, 66, 1)")
.verify.cssProperty("#signInPageMessage", "background-color", "rgba(242, 222, 222, 1)")
.verify.cssProperty("#signInPageMessage", "border-color", "rgb(235, 204, 209)");
},
"anonymous guest should be notified if email already exists": function (client) {
client
.url("http://localhost:3000/entrySignUp")
.resizeWindow(1024, 768)
.signUp("janicedoe@symptomatic.io", "Janiced*e123").pause(500)
.click("#signUpPageJoinNowButton").pause(1000)
.verify.elementPresent("#signUpPageMessage")
.verify.containsText("#signUpPageMessage", "Email already exists. [403]");
},
after: function (client) {
client
.dropEntryUsers()
.end();
}
};