Merge pull request #1797 from vincent99/master

First login
This commit is contained in:
Vincent Fiduccia 2018-04-04 01:35:41 -07:00 committed by GitHub
commit bcf0ce66b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 21 additions and 29 deletions

View File

@ -7,6 +7,7 @@ import C from 'ui/utils/constants';
export default Controller.extend({
router: service(),
access: service(),
settings: service(),
showCurrent: null,
@ -23,6 +24,7 @@ export default Controller.extend({
let backTo = get(this, 'session').get(C.SESSION.BACK_TO)
let router = get(this, 'router');
if (success) {
get(this, 'access').set('firstLogin', false);
get(this, 'access').set('userCode', null);
if ( backTo ) {
// console.log('Going back to', backTo);

View File

@ -8,6 +8,7 @@
user=model.user
showCurrent=showCurrent
currentPassword=currentPassword
editButton=(if firstLogin 'modalEditPassword.firstLogin.actionButton' 'modalEditPassword.actionButton')
cancelDisabled=true
}}
</div>

View File

@ -116,6 +116,7 @@ export default Controller.extend({
code: null,
});
get(this, 'access').set('userCode', null);
get(this, 'access').set('firstLogin', false);
this.send('complete', true);
}
}).catch((err) => {

View File

@ -6,11 +6,8 @@ import C from 'shared/utils/constants';
export default Route.extend({
access: service(),
cookies: service(),
globalStore: service(),
language: service('user-language'),
firstLogin: null,
activate() {
$('BODY').addClass('container-farm');
},
@ -21,18 +18,11 @@ export default Route.extend({
beforeModel() {
this._super(...arguments);
return get(this, 'language').initUnauthed().then(() => {
return this.get('globalStore').request({url: `settings/${C.SETTING.FIRST_LOGIN}`}).then((res) =>{
set(this, 'firstLogin', (res.value+'') === 'true');
}).catch(() => {
set(this, 'firstLogin', false);
});
});
return get(this, 'language').initUnauthed();
},
model() {
const firstLogin = get(this, 'firstLogin');
set(this, 'access.firstLogin', firstLogin);
const firstLogin = get(this,'access.firstLogin');
if ( firstLogin ) {
const code = {
@ -40,18 +30,13 @@ export default Route.extend({
password: 'admin',
};
return get(this, 'access').login('local',code).then((user) => {
return get(this, 'access').login('local',code).then((/*user*/) => {
get(this, 'cookies').setWithOptions(C.COOKIE.USERNAME, 'admin', {expire: 365, secure: 'auto'});
set(this, 'access.userCode', code);
return {
firstLogin: true,
user: user,
changePassword: true,
code: code,
}
this.transitionToExternal('update-password');
}).catch(() => {
return {
firstLogin: true,
user: null,
changePassword: false,
code: null,
@ -67,12 +52,6 @@ export default Route.extend({
}
},
afterModel(model) {
if ( get(model, 'firstLogin') ) {
this.transitionToExternal('update-password');
}
},
resetController(controller, isExisting /*, transition*/ ) {
if (isExisting) {
controller.set('changePassword', false);

View File

@ -3,6 +3,7 @@ import { observer } from '@ember/object';
import { alias } from '@ember/object/computed';
import { on } from '@ember/object/evented';
import { next } from '@ember/runloop';
import { hash } from 'rsvp'
import Service, { inject as service } from '@ember/service';
import C from 'shared/utils/constants';
import { get, set } from '@ember/object';
@ -60,7 +61,10 @@ export default Service.extend({
detect() {
const globalStore = get(this,'globalStore');
return globalStore.request({url: '/v3-public/authProviders'}).then((providers) => {
return hash({
providers: globalStore.request({url: '/v3-public/authProviders'}),
firstSetting: globalStore.request({url: `settings/${C.SETTING.FIRST_LOGIN}`}),
}).then(({providers, firstSetting}) => {
if ( providers && get(providers,'length') ) {
set(this, 'providers', providers);
if (get(providers, 'length') === 1) {
@ -70,6 +74,8 @@ export default Service.extend({
set(this, 'providers', []);
}
set(this, 'firstLogin', (firstSetting.value+'') === 'true');
return this.loadMe();
}).catch((err) => {
next(() => {

View File

@ -19,6 +19,7 @@ export default Component.extend({
showCurrent: true,
generate: false,
setOrChange: CHANGE,
editLabel: 'modalEditPassword.actionButton',
currentPassword: null,
user: null,

View File

@ -44,5 +44,5 @@
</div>
{{top-errors errors=errors}}
{{save-cancel saveDisabled=saveDisabled save="save" editing=true editLabel="modalEditPassword.actionButton" cancel=cancel cancelDisabled=cancelDisabled}}
{{save-cancel saveDisabled=saveDisabled save="save" editing=true editLabel=editButton cancel=cancel cancelDisabled=cancelDisabled}}
</form>

View File

@ -9,6 +9,7 @@ export default Component.extend(ModalBase, {
layout,
classNames: ['medium-modal'],
router: service(),
settings: service(),
showHelp: false,
user: alias('modalOpts.user'),
actions: {

View File

@ -1,5 +1,5 @@
<div class="header">
<h2>{{t 'modalEditPassword.edit.title'}}</h2>
<h2>{{t 'modalEditPassword.edit.title' appName=settings.appName}}</h2>
{{#if showHelp}}
<p class="help-text">{{t 'modalEditPassword.edit.help'}}</p>
{{/if}}

View File

@ -4042,6 +4042,7 @@ modalEditPassword:
firstLogin:
title: Welcome to {appName}
help: The first order of business is to set a strong password for the default <code>admin</code> user.
actionButton: Continue
edit:
title: Change Password
help: Please choose a new password