-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create User & Complete Password Processes (#16)
* #3 Complete password implemented. Still needs testing. * #3 Complete password tested. MFA no longer is two steps to activate. * #17 Starting to create new user. Need to add role select box. * #17 Create user is implemented but error handling is still required. #15 Current user and sign out is improved.
- Loading branch information
Showing
36 changed files
with
669 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import ApplicationAdapter from './application'; | ||
|
||
export default ApplicationAdapter.extend({ | ||
_buildURL(/*modelName, id*/) { | ||
const url = this._super(...arguments); | ||
return url.replace('current-users', 'current-user'); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
import Controller from '@ember/controller'; | ||
|
||
export default Controller.extend({}); | ||
export default Controller.extend({ | ||
email: '', | ||
|
||
queryParams: [ | ||
{ email: { type: 'string' } } | ||
] | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { collectionAction } from 'ember-api-actions'; | ||
import BaseModel from 'ember-cybertooth-base-model/models/-base'; | ||
import DS from 'ember-data'; | ||
|
||
export default BaseModel.extend({ | ||
/* Attributes | ||
* ---------------------------------------------------------------------------------------------------------------- */ | ||
|
||
email: DS.attr('string'), | ||
|
||
/* Relationships | ||
* ---------------------------------------------------------------------------------------------------------------- */ | ||
|
||
roles: DS.hasMany('role'), | ||
sessions: DS.hasMany('session'), | ||
|
||
/* Instance Methods | ||
* ---------------------------------------------------------------------------------------------------------------- */ | ||
|
||
signOut() { | ||
return new Promise((resolve, reject) => { | ||
this._signOut() | ||
.then(() => resolve(this)) | ||
.catch(response => reject(response)) | ||
}); | ||
}, | ||
|
||
/* Custom API end points | ||
* ---------------------------------------------------------------------------------------------------------------- */ | ||
|
||
_signOut: collectionAction({ path: 'sign-out', type: 'PATCH' }) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,25 @@ | ||
import { not, readOnly } from '@ember/object/computed'; | ||
import BaseModel from 'ember-cybertooth-base-model/models/-base'; | ||
import DS from 'ember-data'; | ||
|
||
export default BaseModel.extend({ | ||
|
||
/** Attributes | ||
/* Attributes | ||
* ---------------------------------------------------------------------------------------------------------------- */ | ||
|
||
email: DS.attr('string'), | ||
inCognito: DS.attr('boolean'), | ||
|
||
/** Relationships | ||
/* Relationships | ||
* ---------------------------------------------------------------------------------------------------------------- */ | ||
|
||
roles: DS.hasMany('role'), | ||
sessions: DS.hasMany('session') | ||
sessions: DS.hasMany('session', { inverse: 'user' }), | ||
|
||
/* Computed | ||
* ---------------------------------------------------------------------------------------------------------------- */ | ||
|
||
'inCognito?': readOnly('inCognito'), | ||
|
||
'notInCognito?': not('inCognito?') | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,17 @@ | ||
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin'; | ||
import Route from '@ember/routing/route'; | ||
|
||
export default Route.extend(AuthenticatedRouteMixin, {}); | ||
export default Route.extend(AuthenticatedRouteMixin, { | ||
/** | ||
* Loading the `current-user` into the store; you can peek to get access to it. | ||
* @return {*|Promise} the `current-user` instance. | ||
*/ | ||
model() { | ||
return this.get('store').queryRecord('current-user', { | ||
include: '' + | ||
'roles' + | ||
',sessions' + | ||
'' | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { hash } from 'rsvp'; | ||
import Route from '@ember/routing/route'; | ||
|
||
export default Route.extend({ | ||
model() { | ||
return hash({ | ||
roles: this.get('store').query('role', { sort: 'name' }) | ||
}) | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { isBlank } from '@ember/utils'; | ||
import { get } from '@ember/object'; | ||
import { hash } from 'rsvp'; | ||
import Route from '@ember/routing/route'; | ||
|
||
export default Route.extend({ | ||
actions: { | ||
chooseRole(user, chosenRole) { | ||
if (isBlank(chosenRole)) { | ||
return true; | ||
} | ||
|
||
user.get('roles').pushObject(chosenRole); | ||
return true; | ||
}, | ||
|
||
save(user) { | ||
user | ||
.save() | ||
.then((/*response*/) => { | ||
this.get('notify').success('Created.'); | ||
}) | ||
.catch((errors) => { | ||
console.error('???', errors); | ||
this.get('notify').error('Check for errors.'); | ||
}); | ||
return false; | ||
} | ||
}, | ||
|
||
model() { | ||
return hash({ | ||
roles: get(this.modelFor('protected.configuration.users.new'), 'roles'), | ||
user: this.get('store').createRecord('user') | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import DS from 'ember-data'; | ||
|
||
export default DS.JSONAPISerializer.extend({ | ||
attrs: { | ||
createdAt: { serialize: false }, | ||
updatedAt: { serialize: false } | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.