mirror of
https://github.com/umami-software/umami.git
synced 2026-02-12 00:27:11 +01:00
Updated useConfig. Added SSO page.
This commit is contained in:
parent
f10c8ba9e2
commit
c58e037a7e
8 changed files with 69 additions and 32 deletions
38
pages/sso.js
Normal file
38
pages/sso.js
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
import { useEffect } from 'react';
|
||||
import debug from 'debug';
|
||||
import { useRouter } from 'next/router';
|
||||
import { setItem } from 'next-basics';
|
||||
import { AUTH_TOKEN } from 'lib/constants';
|
||||
import useApi from 'hooks/useApi';
|
||||
import { setUser } from 'store/app';
|
||||
|
||||
const log = debug('umami:sso');
|
||||
|
||||
export default function SingleSignOnPage() {
|
||||
const router = useRouter();
|
||||
const { get } = useApi();
|
||||
const { token, url } = router.query;
|
||||
|
||||
useEffect(() => {
|
||||
async function verify() {
|
||||
setItem(AUTH_TOKEN, token);
|
||||
|
||||
const { ok, data } = await get('/auth/verify');
|
||||
|
||||
if (ok) {
|
||||
log(data);
|
||||
setUser(data);
|
||||
|
||||
if (url) {
|
||||
await router.push(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (token) {
|
||||
verify();
|
||||
}
|
||||
}, [token]);
|
||||
|
||||
return null;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue