sdk.js
738 Bytes
import Login from 'yoho-activity-sdk/src/public/login';
import Base from 'yoho-activity-sdk/src/public/base';
import yoho from 'common/yoho';
import cookie from 'yoho-cookie';
var env = Base.env();
var loginUrl = Base.loginUrl();
var login = new Login({loginUrl: loginUrl, env: env});
async function getUser() {
if (yoho.isApp) {
const user = await Base.getUser();
if (user && user.uid) {
cookie.set('app_uid', user.uid);
cookie.set('app_session_key', user.sessionKey);
cookie.set('app_version', user.appVersion);
cookie.set('app_client_type', user.sessionType);
}
return user;
} else {
return Base.getUser();
}
}
export default {
goLogin: login.goLogin.bind(login),
getUser
};