mirror of
https://github.com/documize/community.git
synced 2025-08-09 07:25:23 +02:00
Add documize and anonymous autheticators
This commit is contained in:
parent
fd42473f99
commit
5bd92b7f63
2 changed files with 33 additions and 15 deletions
12
app/app/authenticators/anonymous.js
Normal file
12
app/app/authenticators/anonymous.js
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
import Ember from 'ember';
|
||||||
|
import Base from 'ember-simple-auth/authenticators/base';
|
||||||
|
|
||||||
|
const {
|
||||||
|
RSVP: { resolve }
|
||||||
|
} = Ember;
|
||||||
|
|
||||||
|
export default Base.extend({
|
||||||
|
authenticate(data) {
|
||||||
|
return resolve(data);
|
||||||
|
}
|
||||||
|
});
|
|
@ -6,36 +6,42 @@ import models from '../utils/model';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
isPresent,
|
isPresent,
|
||||||
RSVP: { resolve, reject }
|
RSVP: { resolve, reject },
|
||||||
|
inject: { service }
|
||||||
} = Ember;
|
} = Ember;
|
||||||
|
|
||||||
export default Base.extend({
|
export default Base.extend({
|
||||||
serverTokenEndpoint: `public/authenticate`,
|
|
||||||
|
|
||||||
ajax: Ember.inject.service(),
|
ajax: service(),
|
||||||
|
appMeta: service(),
|
||||||
|
|
||||||
restore(data) {
|
restore(data) {
|
||||||
|
// TODO: verify authentication data
|
||||||
if (data) {
|
if (data) {
|
||||||
return resolve(data)
|
return resolve(data);
|
||||||
}
|
}
|
||||||
return reject();
|
return reject();
|
||||||
},
|
},
|
||||||
|
|
||||||
authenticate({password, email}) {
|
authenticate({password, email}) {
|
||||||
let domain = netUtil.getSubdomain();
|
let domain = netUtil.getSubdomain();
|
||||||
|
|
||||||
if (!isPresent(password) || !isPresent(email)) {
|
if (!isPresent(password) || !isPresent(email)) {
|
||||||
return Ember.RSVP.reject("invalid");
|
return Ember.RSVP.reject("invalid");
|
||||||
}
|
}
|
||||||
|
|
||||||
var encoded = encodingUtil.Base64.encode(`${domain}:${email}:${password}`);
|
var encoded = encodingUtil.Base64.encode(`${domain}:${email}:${password}`);
|
||||||
|
|
||||||
var headers = {
|
var headers = {
|
||||||
'Authorization': 'Basic ' + encoded
|
'Authorization': 'Basic ' + encoded
|
||||||
};
|
};
|
||||||
|
|
||||||
return this.get('ajax').post('public/authenticate', {
|
return this.get('ajax').post('public/authenticate', {
|
||||||
headers
|
headers
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
invalidate() {
|
||||||
|
return resolve();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue