woodpecker/web/src/compositions/useAuthentication.ts

18 lines
452 B
TypeScript
Raw Normal View History

import useConfig from '~/compositions/useConfig';
import useUserConfig from '~/compositions/useUserConfig';
export default () =>
({
isAuthenticated: !!useConfig().user,
user: useConfig().user,
authenticate(url?: string) {
if (url !== undefined) {
const config = useUserConfig();
config.setUserConfig('redirectUrl', url);
}
window.location.href = `${useConfig().rootPath}/login`;
},
}) as const;