admin login
Some checks are pending
Run tests / test-runner (push) Waiting to run

This commit is contained in:
Jan Prochazka 2024-07-26 16:40:17 +02:00
parent f697ba03f8
commit 38a80ec695
2 changed files with 15 additions and 2 deletions

View File

@ -58,7 +58,17 @@ module.exports = {
},
login_meta: true,
async login(params) {
const { login, password } = params;
const { login, password, isAdminPage } = params;
if (isAdminPage) {
if (process.env.ADMIN_PASSWORD && process.env.ADMIN_PASSWORD == password) {
return {
accessToken: jwt.sign({ login: 'admin' }, getTokenSecret(), { expiresIn: getTokenLifetime() }),
};
}
return { error: 'Login failed' };
}
return getAuthProvider().login(login, password);
},

View File

@ -35,7 +35,10 @@
value={isAdminPage ? 'Log In as Administrator' : 'Log In'}
on:click={async e => {
enableApi();
const resp = await apiCall('auth/login', e.detail);
const resp = await apiCall('auth/login', {
isAdminPage,
...e.detail,
});
if (resp.error) {
internalRedirectTo(`/?page=not-logged&error=${encodeURIComponent(resp.error)}`);
return;