Directly login with the only OAuth provider.

This commit is contained in:
Yang Luo
2021-08-07 00:14:24 +08:00
parent 9fb4b4d394
commit 0a461bf19e
2 changed files with 13 additions and 3 deletions

View File

@ -19,6 +19,7 @@ import * as AuthBackend from "./AuthBackend";
import * as Util from "./Util";
import {authConfig} from "./Auth";
import * as Setting from "../Setting";
import i18next from "i18next";
class AuthCallback extends React.Component {
constructor(props) {
@ -121,7 +122,7 @@ class AuthCallback extends React.Component {
<div style={{textAlign: "center"}}>
{
(this.state.msg === null) ? (
<Spin size="large" tip="Signing in..." style={{paddingTop: "10%"}} />
<Spin size="large" tip={i18next.t("login:Signing in...")} style={{paddingTop: "10%"}} />
) : (
Util.renderMessageLarge(this, this.state.msg)
)

View File

@ -14,7 +14,7 @@
import React from "react";
import {Link} from "react-router-dom";
import {Button, Checkbox, Col, Form, Input, Result, Row} from "antd";
import {Button, Checkbox, Col, Form, Input, Result, Row, Spin} from "antd";
import {LockOutlined, UserOutlined} from "@ant-design/icons";
import * as AuthBackend from "./AuthBackend";
import * as ApplicationBackend from "../backend/ApplicationBackend";
@ -232,7 +232,6 @@ class LoginPage extends React.Component {
initialValues={{
organization: application.organization,
application: application.name,
remember: true,
autoSignin: true,
}}
onFinish={(values) => {this.onFinish(values)}}
@ -381,6 +380,16 @@ class LoginPage extends React.Component {
return Util.renderMessageLarge(this, this.state.msg);
}
const visibleOAuthProviderItems = application.providers.filter(providerItem => this.isProviderVisible(providerItem));
if (this.props.application === undefined && visibleOAuthProviderItems.length === 1) {
Setting.goToLink(Provider.getAuthUrl(application, visibleOAuthProviderItems[0].provider, "signup"));
return (
<div style={{textAlign: "center"}}>
<Spin size="large" tip={i18next.t("login:Signing in...")} style={{paddingTop: "10%"}} />
</div>
)
}
return (
<Row>
<Col span={24} style={{display: "flex", justifyContent: "center"}}>