2016-03-29 02:36:48 +02:00
|
|
|
export const STATES = {
|
|
|
|
SIGN_IN: Symbol('SIGN_IN'),
|
|
|
|
SIGN_UP: Symbol('SIGN_UP'),
|
|
|
|
SIGN_OUT: Symbol('SIGN_OUT'),
|
|
|
|
PASSWORD_CHANGE: Symbol('PASSWORD_CHANGE'),
|
|
|
|
PASSWORD_RESET: Symbol('PASSWORD_RESET')
|
2016-03-28 22:34:50 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export function getLoginServices() {
|
|
|
|
// First look for OAuth services.
|
|
|
|
const services = Package['accounts-oauth'] ? Accounts.oauth.serviceNames() : [];
|
|
|
|
|
|
|
|
// Be equally kind to all login services. This also preserves
|
|
|
|
// backwards-compatibility.
|
|
|
|
services.sort();
|
|
|
|
|
|
|
|
return _.map(services, function(name){
|
|
|
|
return {name: name};
|
|
|
|
});
|
|
|
|
};
|
|
|
|
// Export getLoginServices using old style globals for accounts-base which
|
|
|
|
// requires it.
|
|
|
|
this.getLoginServices = getLoginServices;
|
|
|
|
|
2016-03-29 01:28:53 +02:00
|
|
|
export function loginResultCallback(redirect, error) {
|
|
|
|
if (Meteor.isClient) {
|
2016-03-28 22:34:50 +02:00
|
|
|
if (typeof redirect === 'string'){
|
|
|
|
window.location.href = redirect;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (typeof redirect === 'function'){
|
|
|
|
redirect();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export function passwordSignupFields() {
|
|
|
|
return Accounts.ui._options.passwordSignupFields || "EMAIL_ONLY";
|
|
|
|
};
|
|
|
|
|
|
|
|
export function validatePassword(password){
|
2016-03-31 03:21:45 +02:00
|
|
|
if (password.length >= 7) {
|
2016-03-28 22:34:50 +02:00
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-03-29 04:37:10 +02:00
|
|
|
export function redirect(redirect) {
|
2016-03-28 22:34:50 +02:00
|
|
|
if (Meteor.isClient) {
|
|
|
|
if (window.history) {
|
2016-03-29 04:37:10 +02:00
|
|
|
Meteor.setTimeout(() => {
|
|
|
|
if (Package['kadira:flow-router']) {
|
|
|
|
Package['kadira:flow-router'].FlowRouter.go(redirect);
|
|
|
|
}
|
|
|
|
else if (Package['kadira:flow-router-ssr']) {
|
|
|
|
Package['kadira:flow-router-ssr'].FlowRouter.go(redirect);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
window.history.pushState( {} , 'redirect', redirect );
|
|
|
|
}
|
|
|
|
}, 500);
|
2016-03-28 22:34:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|