mirror of
https://github.com/grafana/grafana.git
synced 2024-12-29 10:21:41 -06:00
Auth: Hide forgot password if grafana auth is disabled (#79895)
* hide forgot password if grafana auth is disabled * fix test
This commit is contained in:
parent
e924627659
commit
5ae3249c36
@ -259,4 +259,6 @@ export interface AuthSettings {
|
||||
GoogleSkipOrgRoleSync?: boolean;
|
||||
// @deprecated -- this is no longer used and will be removed in Grafana 11
|
||||
GenericOAuthSkipOrgRoleSync?: boolean;
|
||||
|
||||
disableLogin?: boolean;
|
||||
}
|
||||
|
@ -29,6 +29,8 @@ type FrontendSettingsAuthDTO struct {
|
||||
GitLabSkipOrgRoleSync bool `json:"GitLabSkipOrgRoleSync"`
|
||||
// Deprecated: this is no longer used and will be removed in Grafana 11
|
||||
OktaSkipOrgRoleSync bool `json:"OktaSkipOrgRoleSync"`
|
||||
|
||||
DisableLogin bool `json:"disableLogin"`
|
||||
}
|
||||
|
||||
type FrontendSettingsBuildInfoDTO struct {
|
||||
|
@ -329,6 +329,7 @@ func (hs *HTTPServer) getFrontendSettings(c *contextmodel.ReqContext) (*dtos.Fro
|
||||
GithubSkipOrgRoleSync: parseSkipOrgRoleSyncEnabled(oauthProviders[social.GitHubProviderName]),
|
||||
GitLabSkipOrgRoleSync: parseSkipOrgRoleSyncEnabled(oauthProviders[social.GitlabProviderName]),
|
||||
OktaSkipOrgRoleSync: parseSkipOrgRoleSyncEnabled(oauthProviders[social.OktaProviderName]),
|
||||
DisableLogin: hs.Cfg.DisableLogin,
|
||||
}
|
||||
|
||||
if hs.pluginsCDNService != nil && hs.pluginsCDNService.IsEnabled() {
|
||||
|
@ -551,7 +551,7 @@ type Cfg struct {
|
||||
// AddChangePasswordLink returns if login form is disabled or not since
|
||||
// the same intention can be used to hide both features.
|
||||
func (cfg *Cfg) AddChangePasswordLink() bool {
|
||||
return !cfg.DisableLoginForm
|
||||
return !(cfg.DisableLoginForm || cfg.DisableLogin)
|
||||
}
|
||||
|
||||
type CommandLineArgs struct {
|
||||
|
@ -14,6 +14,9 @@ jest.mock('@grafana/runtime', () => ({
|
||||
post: postMock,
|
||||
}),
|
||||
config: {
|
||||
auth: {
|
||||
disableLogin: false,
|
||||
},
|
||||
loginError: false,
|
||||
buildInfo: {
|
||||
version: 'v1.0',
|
||||
|
@ -4,9 +4,9 @@ import React from 'react';
|
||||
|
||||
// Components
|
||||
import { GrafanaTheme2 } from '@grafana/data';
|
||||
import { config } from '@grafana/runtime';
|
||||
import { Alert, HorizontalGroup, LinkButton, useStyles2 } from '@grafana/ui';
|
||||
import { Branding } from 'app/core/components/Branding/Branding';
|
||||
import config from 'app/core/config';
|
||||
import { t } from 'app/core/internationalization';
|
||||
|
||||
import { ChangePassword } from '../ForgottenPassword/ChangePassword';
|
||||
@ -48,13 +48,15 @@ export const LoginPage = () => {
|
||||
{!disableLoginForm && (
|
||||
<LoginForm onSubmit={login} loginHint={loginHint} passwordHint={passwordHint} isLoggingIn={isLoggingIn}>
|
||||
<HorizontalGroup justify="flex-end">
|
||||
<LinkButton
|
||||
className={styles.forgottenPassword}
|
||||
fill="text"
|
||||
href={`${config.appSubUrl}/user/password/send-reset-email`}
|
||||
>
|
||||
Forgot your password?
|
||||
</LinkButton>
|
||||
{!config.auth.disableLogin && (
|
||||
<LinkButton
|
||||
className={styles.forgottenPassword}
|
||||
fill="text"
|
||||
href={`${config.appSubUrl}/user/password/send-reset-email`}
|
||||
>
|
||||
Forgot your password?
|
||||
</LinkButton>
|
||||
)}
|
||||
</HorizontalGroup>
|
||||
</LoginForm>
|
||||
)}
|
||||
|
Loading…
Reference in New Issue
Block a user