2021-01-22 11:11:24 +08:00
|
|
|
import { Context } from '@nuxt/types';
|
|
|
|
|
2021-03-13 18:10:56 +08:00
|
|
|
export default ({ app: { $cookies }, $auth, redirect }: Context) => {
|
2021-02-04 17:34:24 +08:00
|
|
|
if ($cookies.get('returnRoute')) {
|
2021-01-22 13:18:09 +08:00
|
|
|
// is returning from login
|
2021-01-23 03:20:03 +08:00
|
|
|
const returnRoute = $cookies.get<string>('returnRoute');
|
2021-02-04 17:34:24 +08:00
|
|
|
$cookies.remove('returnRoute', {
|
|
|
|
path: '/',
|
2021-01-22 13:18:09 +08:00
|
|
|
});
|
2021-02-04 17:34:24 +08:00
|
|
|
$cookies.remove('url', {
|
|
|
|
path: '/',
|
|
|
|
});
|
|
|
|
redirect(returnRoute);
|
2021-03-10 12:07:53 +08:00
|
|
|
// TODO if not running hangarauth locally, this needs to just be a regular if not an else-if (idk what a good fix for that is)
|
|
|
|
} else if ($cookies.get('HangarAuth_REFRESH', { parseJSON: false })) {
|
2021-03-13 18:10:56 +08:00
|
|
|
return $auth.refreshUser();
|
2021-01-22 11:11:24 +08:00
|
|
|
}
|
|
|
|
};
|