mirror of https://github.com/rancher/ui.git
commit
bcf0ce66b5
|
|
@ -7,6 +7,7 @@ import C from 'ui/utils/constants';
|
||||||
export default Controller.extend({
|
export default Controller.extend({
|
||||||
router: service(),
|
router: service(),
|
||||||
access: service(),
|
access: service(),
|
||||||
|
settings: service(),
|
||||||
|
|
||||||
showCurrent: null,
|
showCurrent: null,
|
||||||
|
|
||||||
|
|
@ -23,6 +24,7 @@ export default Controller.extend({
|
||||||
let backTo = get(this, 'session').get(C.SESSION.BACK_TO)
|
let backTo = get(this, 'session').get(C.SESSION.BACK_TO)
|
||||||
let router = get(this, 'router');
|
let router = get(this, 'router');
|
||||||
if (success) {
|
if (success) {
|
||||||
|
get(this, 'access').set('firstLogin', false);
|
||||||
get(this, 'access').set('userCode', null);
|
get(this, 'access').set('userCode', null);
|
||||||
if ( backTo ) {
|
if ( backTo ) {
|
||||||
// console.log('Going back to', backTo);
|
// console.log('Going back to', backTo);
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
user=model.user
|
user=model.user
|
||||||
showCurrent=showCurrent
|
showCurrent=showCurrent
|
||||||
currentPassword=currentPassword
|
currentPassword=currentPassword
|
||||||
|
editButton=(if firstLogin 'modalEditPassword.firstLogin.actionButton' 'modalEditPassword.actionButton')
|
||||||
cancelDisabled=true
|
cancelDisabled=true
|
||||||
}}
|
}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,7 @@ export default Controller.extend({
|
||||||
code: null,
|
code: null,
|
||||||
});
|
});
|
||||||
get(this, 'access').set('userCode', null);
|
get(this, 'access').set('userCode', null);
|
||||||
|
get(this, 'access').set('firstLogin', false);
|
||||||
this.send('complete', true);
|
this.send('complete', true);
|
||||||
}
|
}
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,8 @@ import C from 'shared/utils/constants';
|
||||||
export default Route.extend({
|
export default Route.extend({
|
||||||
access: service(),
|
access: service(),
|
||||||
cookies: service(),
|
cookies: service(),
|
||||||
globalStore: service(),
|
|
||||||
language: service('user-language'),
|
language: service('user-language'),
|
||||||
|
|
||||||
firstLogin: null,
|
|
||||||
|
|
||||||
activate() {
|
activate() {
|
||||||
$('BODY').addClass('container-farm');
|
$('BODY').addClass('container-farm');
|
||||||
},
|
},
|
||||||
|
|
@ -21,18 +18,11 @@ export default Route.extend({
|
||||||
|
|
||||||
beforeModel() {
|
beforeModel() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
return get(this, 'language').initUnauthed().then(() => {
|
return get(this, 'language').initUnauthed();
|
||||||
return this.get('globalStore').request({url: `settings/${C.SETTING.FIRST_LOGIN}`}).then((res) =>{
|
|
||||||
set(this, 'firstLogin', (res.value+'') === 'true');
|
|
||||||
}).catch(() => {
|
|
||||||
set(this, 'firstLogin', false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
model() {
|
model() {
|
||||||
const firstLogin = get(this, 'firstLogin');
|
const firstLogin = get(this,'access.firstLogin');
|
||||||
set(this, 'access.firstLogin', firstLogin);
|
|
||||||
|
|
||||||
if ( firstLogin ) {
|
if ( firstLogin ) {
|
||||||
const code = {
|
const code = {
|
||||||
|
|
@ -40,18 +30,13 @@ export default Route.extend({
|
||||||
password: 'admin',
|
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'});
|
get(this, 'cookies').setWithOptions(C.COOKIE.USERNAME, 'admin', {expire: 365, secure: 'auto'});
|
||||||
|
|
||||||
set(this, 'access.userCode', code);
|
set(this, 'access.userCode', code);
|
||||||
return {
|
this.transitionToExternal('update-password');
|
||||||
firstLogin: true,
|
|
||||||
user: user,
|
|
||||||
changePassword: true,
|
|
||||||
code: code,
|
|
||||||
}
|
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
return {
|
return {
|
||||||
|
firstLogin: true,
|
||||||
user: null,
|
user: null,
|
||||||
changePassword: false,
|
changePassword: false,
|
||||||
code: null,
|
code: null,
|
||||||
|
|
@ -67,12 +52,6 @@ export default Route.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
afterModel(model) {
|
|
||||||
if ( get(model, 'firstLogin') ) {
|
|
||||||
this.transitionToExternal('update-password');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
resetController(controller, isExisting /*, transition*/ ) {
|
resetController(controller, isExisting /*, transition*/ ) {
|
||||||
if (isExisting) {
|
if (isExisting) {
|
||||||
controller.set('changePassword', false);
|
controller.set('changePassword', false);
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { observer } from '@ember/object';
|
||||||
import { alias } from '@ember/object/computed';
|
import { alias } from '@ember/object/computed';
|
||||||
import { on } from '@ember/object/evented';
|
import { on } from '@ember/object/evented';
|
||||||
import { next } from '@ember/runloop';
|
import { next } from '@ember/runloop';
|
||||||
|
import { hash } from 'rsvp'
|
||||||
import Service, { inject as service } from '@ember/service';
|
import Service, { inject as service } from '@ember/service';
|
||||||
import C from 'shared/utils/constants';
|
import C from 'shared/utils/constants';
|
||||||
import { get, set } from '@ember/object';
|
import { get, set } from '@ember/object';
|
||||||
|
|
@ -60,7 +61,10 @@ export default Service.extend({
|
||||||
detect() {
|
detect() {
|
||||||
const globalStore = get(this,'globalStore');
|
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') ) {
|
if ( providers && get(providers,'length') ) {
|
||||||
set(this, 'providers', providers);
|
set(this, 'providers', providers);
|
||||||
if (get(providers, 'length') === 1) {
|
if (get(providers, 'length') === 1) {
|
||||||
|
|
@ -70,6 +74,8 @@ export default Service.extend({
|
||||||
set(this, 'providers', []);
|
set(this, 'providers', []);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set(this, 'firstLogin', (firstSetting.value+'') === 'true');
|
||||||
|
|
||||||
return this.loadMe();
|
return this.loadMe();
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
next(() => {
|
next(() => {
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ export default Component.extend({
|
||||||
showCurrent: true,
|
showCurrent: true,
|
||||||
generate: false,
|
generate: false,
|
||||||
setOrChange: CHANGE,
|
setOrChange: CHANGE,
|
||||||
|
editLabel: 'modalEditPassword.actionButton',
|
||||||
currentPassword: null,
|
currentPassword: null,
|
||||||
user: null,
|
user: null,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,5 +44,5 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{top-errors errors=errors}}
|
{{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>
|
</form>
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ export default Component.extend(ModalBase, {
|
||||||
layout,
|
layout,
|
||||||
classNames: ['medium-modal'],
|
classNames: ['medium-modal'],
|
||||||
router: service(),
|
router: service(),
|
||||||
|
settings: service(),
|
||||||
showHelp: false,
|
showHelp: false,
|
||||||
user: alias('modalOpts.user'),
|
user: alias('modalOpts.user'),
|
||||||
actions: {
|
actions: {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<h2>{{t 'modalEditPassword.edit.title'}}</h2>
|
<h2>{{t 'modalEditPassword.edit.title' appName=settings.appName}}</h2>
|
||||||
{{#if showHelp}}
|
{{#if showHelp}}
|
||||||
<p class="help-text">{{t 'modalEditPassword.edit.help'}}</p>
|
<p class="help-text">{{t 'modalEditPassword.edit.help'}}</p>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
||||||
|
|
@ -4042,6 +4042,7 @@ modalEditPassword:
|
||||||
firstLogin:
|
firstLogin:
|
||||||
title: Welcome to {appName}
|
title: Welcome to {appName}
|
||||||
help: The first order of business is to set a strong password for the default <code>admin</code> user.
|
help: The first order of business is to set a strong password for the default <code>admin</code> user.
|
||||||
|
actionButton: Continue
|
||||||
edit:
|
edit:
|
||||||
title: Change Password
|
title: Change Password
|
||||||
help: Please choose a new password
|
help: Please choose a new password
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue