mirror of https://github.com/rancher/ui.git
commit
bcf0ce66b5
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
user=model.user
|
||||
showCurrent=showCurrent
|
||||
currentPassword=currentPassword
|
||||
editButton=(if firstLogin 'modalEditPassword.firstLogin.actionButton' 'modalEditPassword.actionButton')
|
||||
cancelDisabled=true
|
||||
}}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -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) => {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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(() => {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ export default Component.extend({
|
|||
showCurrent: true,
|
||||
generate: false,
|
||||
setOrChange: CHANGE,
|
||||
editLabel: 'modalEditPassword.actionButton',
|
||||
currentPassword: null,
|
||||
user: null,
|
||||
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ export default Component.extend(ModalBase, {
|
|||
layout,
|
||||
classNames: ['medium-modal'],
|
||||
router: service(),
|
||||
settings: service(),
|
||||
showHelp: false,
|
||||
user: alias('modalOpts.user'),
|
||||
actions: {
|
||||
|
|
|
|||
|
|
@ -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}}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue