mirror of
https://github.com/umami-software/umami.git
synced 2026-02-18 11:35:37 +01:00
autologin as separate component
This commit is contained in:
parent
6bd01aaa45
commit
e849d55b3f
3 changed files with 30 additions and 16 deletions
24
components/forms/AutoLogin.js
Normal file
24
components/forms/AutoLogin.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import React from 'react';
|
||||
import { useRouter } from 'next/router';
|
||||
import usePost from 'hooks/usePost';
|
||||
|
||||
export default function AutoLogin({ hash = null }) {
|
||||
const post = usePost();
|
||||
const router = useRouter();
|
||||
|
||||
const handleAutologin = async ({ hash }) => {
|
||||
const autologin = await post('/api/auth/hash', {
|
||||
hash,
|
||||
});
|
||||
|
||||
if (autologin.ok) {
|
||||
return router.push('/');
|
||||
}
|
||||
};
|
||||
|
||||
if (hash) {
|
||||
handleAutologin({ hash });
|
||||
}
|
||||
|
||||
return <div />;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue