mirror of
https://github.com/documize/community.git
synced 2025-08-08 06:55:28 +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 {
|
||||
isPresent,
|
||||
RSVP: { resolve, reject }
|
||||
RSVP: { resolve, reject },
|
||||
inject: { service }
|
||||
} = Ember;
|
||||
|
||||
export default Base.extend({
|
||||
serverTokenEndpoint: `public/authenticate`,
|
||||
|
||||
ajax: Ember.inject.service(),
|
||||
ajax: service(),
|
||||
appMeta: service(),
|
||||
|
||||
restore(data) {
|
||||
// TODO: verify authentication data
|
||||
if (data) {
|
||||
return resolve(data)
|
||||
return resolve(data);
|
||||
}
|
||||
return reject();
|
||||
},
|
||||
|
||||
authenticate({password, email}) {
|
||||
let domain = netUtil.getSubdomain();
|
||||
let domain = netUtil.getSubdomain();
|
||||
|
||||
if (!isPresent(password) || !isPresent(email)) {
|
||||
return Ember.RSVP.reject("invalid");
|
||||
}
|
||||
if (!isPresent(password) || !isPresent(email)) {
|
||||
return Ember.RSVP.reject("invalid");
|
||||
}
|
||||
|
||||
var encoded = encodingUtil.Base64.encode(`${domain}:${email}:${password}`);
|
||||
var encoded = encodingUtil.Base64.encode(`${domain}:${email}:${password}`);
|
||||
|
||||
var headers = {
|
||||
'Authorization': 'Basic ' + encoded
|
||||
};
|
||||
var headers = {
|
||||
'Authorization': 'Basic ' + encoded
|
||||
};
|
||||
|
||||
return this.get('ajax').post('public/authenticate', {
|
||||
headers
|
||||
});
|
||||
return this.get('ajax').post('public/authenticate', {
|
||||
headers
|
||||
});
|
||||
},
|
||||
|
||||
invalidate() {
|
||||
return resolve();
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue