36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
export default defineNuxtRouteMiddleware(async (to, from) => {
|
|
const responseJson = await _crossCtl.doComm('select', 'user', {});
|
|
|
|
console.log('responseJson=', responseJson);
|
|
|
|
if (responseJson['responseCode'] == 200) {
|
|
_crossCtl.setAuthInfo(responseJson['data'][0]);
|
|
|
|
_crossCtl.setUserInfo(responseJson['data'][0]);
|
|
|
|
if (_crossCtl.isAuthenticated.value) {
|
|
const tmpProfile = responseJson['data'][0].userInfo.profile;
|
|
// console.log('huk', tmpProfile);
|
|
const profile = {
|
|
email: tmpProfile.infos.email,
|
|
displayName: tmpProfile.display_name,
|
|
photoUrl: tmpProfile.photo_url,
|
|
phone: tmpProfile.infos.phone ? tmpProfile.infos.phone : '',
|
|
memo: tmpProfile.infos.memo ? tmpProfile.infos.memo : '',
|
|
};
|
|
_crossCtl.setUserProfile(profile);
|
|
} else {
|
|
_crossCtl.setUserProfile({});
|
|
}
|
|
return null;
|
|
} else {
|
|
console.log('from = ', from, ', to = ', to);
|
|
_crossCtl.setUserProfile({});
|
|
if (to.fullPath != '/') {
|
|
return throwError('#' + responseJson['responseCode']);
|
|
} else {
|
|
console.log('skip for google...');
|
|
}
|
|
}
|
|
});
|