2016-07-07 18:54:16 -07:00
|
|
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
|
|
|
//
|
2016-07-28 16:49:31 +02:00
|
|
|
// This software (Documize Community Edition) is licensed under
|
2016-07-07 18:54:16 -07:00
|
|
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
|
|
|
//
|
|
|
|
// You can operate outside the AGPL restrictions by purchasing
|
|
|
|
// Documize Enterprise Edition and obtaining a commercial license
|
2016-07-28 16:49:31 +02:00
|
|
|
// by contacting <sales@documize.com>.
|
2016-07-07 18:54:16 -07:00
|
|
|
//
|
|
|
|
// https://documize.com
|
|
|
|
|
|
|
|
import Ember from 'ember';
|
|
|
|
import NotifierMixin from "../../mixins/notifier";
|
|
|
|
import Encoding from "../../utils/encoding";
|
2017-08-27 16:39:09 +01:00
|
|
|
import netUtil from '../../utils/net';
|
2016-07-07 18:54:16 -07:00
|
|
|
|
|
|
|
export default Ember.Controller.extend(NotifierMixin, {
|
|
|
|
|
|
|
|
ajax: Ember.inject.service(),
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
save() {
|
2016-07-28 16:49:31 +02:00
|
|
|
return this.get('ajax').request("/setup", {
|
2016-07-07 18:54:16 -07:00
|
|
|
method: 'POST',
|
|
|
|
data: this.model,
|
|
|
|
dataType: "text",
|
|
|
|
}).then(() => {
|
2017-08-27 16:39:09 +01:00
|
|
|
let dom = netUtil.getSubdomain();
|
|
|
|
var credentials = Encoding.Base64.encode(dom + ":" + this.model.email + ":" + this.model.password);
|
2016-07-07 18:54:16 -07:00
|
|
|
window.location.href = "/auth/sso/" + encodeURIComponent(credentials);
|
2017-03-19 11:37:18 +00:00
|
|
|
}).catch((error) => { // eslint-disable-line no-unused-vars
|
2016-07-07 18:54:16 -07:00
|
|
|
// TODO notify user of the error within the GUI
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2016-07-28 16:49:31 +02:00
|
|
|
});
|