mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
This commit is contained in:
parent
f697ba03f8
commit
38a80ec695
@ -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);
|
||||
},
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user