mirror of https://github.com/rancher/ui.git
40 lines
1.0 KiB
JavaScript
40 lines
1.0 KiB
JavaScript
import { inject as service } from '@ember/service';
|
|
import Controller from '@ember/controller';
|
|
import fetch from 'ember-api-store/utils/fetch';
|
|
|
|
export default Controller.extend({
|
|
access: service(),
|
|
accountCreated: false,
|
|
loading: false,
|
|
canSend: false,
|
|
|
|
actions: {
|
|
createAcct: function() {
|
|
var body = this.get('model');
|
|
body.token = this.get('token');
|
|
|
|
this.set('loading', true);
|
|
|
|
fetch('/create-user', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify(body)
|
|
}).then(() => {
|
|
let code = `${body.email}:${body.pw}`;
|
|
this.get('access').login(code).then(() => {
|
|
this.transitionToRoute('authenticated')
|
|
this.set('loading', false);
|
|
}).catch(err => {
|
|
this.set('saving', false);
|
|
this.set('errors', [err.body.detail]);
|
|
});
|
|
}).catch((err) => {
|
|
this.set('saving', false);
|
|
this.set('errors', [err.body.detail]);
|
|
});
|
|
},
|
|
}
|
|
});
|