Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
Fix/space in username (#1004)
Browse files Browse the repository at this point in the history
* added basic translations for report

* feat: added report model

* feat: added report tabs to visit page

* feat: added report route to router

* feat: added report page

* feat: reports to visits children

* feat: added add/delete report capabilities

* fix: fixed diagnosisContainer issue on browser back history button

* fix: display different report title based on type of visit

* Modified Package.json for new NPM Deployment

* fix: added next appointment and operative plans to opd form

* Restore package.json to working state

* Implement custom forms for OPD Report

* Add custom forms attribute to report model

* fix: saved report object

* fix: added preview report feat

* fix: added report by visit view

* fix: added logic to show different report sections

* fix: added some report translations

* fix: edited report model

* fix: implemented logic to toggle between show report and new report

* Remove preview functionality from OPD Reports

* Implement print button

* Remove print section header

* Write styles and markup for print page

* Refactor report header into partial

* Rename report types

* fix style lint errors

* fix: completed internationalization and lint fix

* 0.9.18

* Incremented version number, added scope

* fix: remove patientId field, fixed next appointment bug, removed unused translation

* fix: change date fields to simple text

* fix: fixed bug that has to do with page header title

* Added .travis.yml file for building and deploying to npm

* Removed ember test. Pretty much does the same as npm test

* Allowing all branches to be tested and built

* fix: added translations for discharge report

* fix: modified report model to accommodate discharge report

* fix: added discharge report

* fix: added next appointment date to discharge report on save

* fix: implemented next appointment as a mixin

* fix: added translations for followup appointment message

* fix: made sure a followup appointment exists before you generate discharge report

* Add Hospital Info report header as option config

* Add report model to patient-diagnosis and visit unit tests

* fix: fixed report header conflict

* Refactor report template

* Add custom forms to discharge report

* fix: added hospital info doc to environment

* fix: create sample docs on couchdb

* Change how "new" routes work

Makes sure that if user redirects to url the patient is properly
selected.

* fix: made sure sample docs are created when deleted

* Add query parameters to improve app navigation experience

* set patient on visit models

* Redirect reports/new to patients when no visit model

* Clean up visit controller

* Set visit on models

* Update visit acceptance tests

* Fix appointments new surgery test error

* Remove double reference to visits controller

* Display visit diagnosis appropriately

* Fix Operative Plans display

* fix: fixed translation lables for next appointments

* fix: modified get futureAppointment to work for list of appointments

* fix: implemented next appointments on both template and controller

* fix: fix lint

* FIx next appointments display

* Added auto trigger hospitalrun-server refresh script on successful build

* Fix reports controller bug

* Add diagnosis container

* Set patient on model if model is not new

* Set visit on controller and add display current operative plan

* Add `Completed By` field to report

* Refactor reports template

* Ensure reports.edit returns to visits.edit

* Display patient procedures on report

* Remove discharge report compulsory next appointment modal

* Fix `completed by` on report page

* Style select element properly; Add titles to report

* fix: fix  new user title bug after a new user has been added

* Added deploy branches to .travis.yml

* fix: fix  test for new user title bug

* fix: updated report template with testing attributes on fields

* fix: update visit template with testing attributes on fields

* fix: implemented acceptance tests for opd and discharge reports

* Implement acceptance tests for OPD Report

* Refactor code to conform with style guide

* fix: trimmed username

* fix: test for trimmed username bug

* Fix nextAppointment bug

* fix: removed unneeded codes

* fix: removed unneeded sample doc

* fix: cleaned to database.js service
  • Loading branch information
Chima Alaebo authored and jkleinsc committed Mar 20, 2017
1 parent 9bc5637 commit 89d6b90
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 15 deletions.
6 changes: 5 additions & 1 deletion app/authenticators/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ export default BaseAuthenticator.extend({
}

return new Ember.RSVP.Promise((resolve, reject) => {
let data = { name: credentials.identification, password: credentials.password };
let username = credentials.identification;
if (typeof username === 'string' && username) {
username = username.trim();
}
let data = { name: username, password: credentials.password };
this._makeRequest('POST', data).then((response) => {
response.name = data.name;
response.expires_at = this._absolutizeExpirationTime(600);
Expand Down
47 changes: 33 additions & 14 deletions tests/acceptance/#-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,24 @@ module('Acceptance | login', {
});

test('visiting / redirects user to login', function(assert) {
assert.expect(3);
assert.expect(1);
runWithPouchDump('default', function() {
visit('/');

stubRequest('post', '/db/_session', function(request) {
assert.equal(request.requestBody, 'name=hradmin&password=test', 'credential are sent to the server');
request.ok({ 'ok': true, 'name': 'hradmin', 'roles': ['System Administrator', 'admin', 'user'] });
});

stubRequest('post', '/chkuser', function(request) {
assert.equal(request.requestBody, 'name=hradmin', 'username is sent to /chkuser');
request.ok({ 'prefix': 'p1', 'role': 'System Administrator' });
});

andThen(function() {
assert.equal(currentURL(), '/#');
});

fillIn('#identification', 'hradmin');
fillIn('#password', 'test');
click('button:contains(#)');
});
});

test('login with correct credentials', function(assert) {
login(assert);
});
test('login with correct credentials but space around username', function(assert) {
login(assert, true);
});

test('incorrect credentials shows an error message on the screen', function(assert) {
assert.expect(2);
runWithPouchDump('default', function() {
Expand All @@ -63,3 +57,28 @@ test('incorrect credentials shows an error message on the screen', function(asse

});
});

function login(assert, spaceAroundUsername) {
assert.expect(3);
runWithPouchDump('default', function() {
visit('/#');

stubRequest('post', '/db/_session', function(request) {
assert.equal(request.requestBody, 'name=hradmin&password=test', !spaceAroundUsername ? 'credential are sent to the server' : 'username trimmed and credential are sent to the server');
request.ok({ 'ok': true, 'name': 'hradmin', 'roles': ['System Administrator', 'admin', 'user'] });
});

stubRequest('post', '/chkuser', function(request) {
assert.equal(request.requestBody, 'name=hradmin', !spaceAroundUsername ? 'username is sent to /chkuser' : 'trimmed username is sent to /chkuser');
request.ok({ 'prefix': 'p1', 'role': 'System Administrator' });
});

andThen(function() {
assert.equal(currentURL(), '/#');
});

fillIn('#identification', !spaceAroundUsername ? 'hradmin' : ' hradmin');
fillIn('#password', 'test');
click('button:contains(#)');
});
}

0 comments on commit 89d6b90

Please # to comment.