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,
|
login_meta: true,
|
||||||
async login(params) {
|
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);
|
return getAuthProvider().login(login, password);
|
||||||
},
|
},
|
||||||
|
@ -35,7 +35,10 @@
|
|||||||
value={isAdminPage ? 'Log In as Administrator' : 'Log In'}
|
value={isAdminPage ? 'Log In as Administrator' : 'Log In'}
|
||||||
on:click={async e => {
|
on:click={async e => {
|
||||||
enableApi();
|
enableApi();
|
||||||
const resp = await apiCall('auth/login', e.detail);
|
const resp = await apiCall('auth/login', {
|
||||||
|
isAdminPage,
|
||||||
|
...e.detail,
|
||||||
|
});
|
||||||
if (resp.error) {
|
if (resp.error) {
|
||||||
internalRedirectTo(`/?page=not-logged&error=${encodeURIComponent(resp.error)}`);
|
internalRedirectTo(`/?page=not-logged&error=${encodeURIComponent(resp.error)}`);
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user