Add app's EnablePassword.

This commit is contained in:
Yang Luo 2021-02-14 10:56:37 +08:00
parent 8543d09d05
commit 4b66c24bb6
4 changed files with 24 additions and 7 deletions

View File

@ -27,6 +27,7 @@ type Application struct {
DisplayName string `xorm:"varchar(100)" json:"displayName"` DisplayName string `xorm:"varchar(100)" json:"displayName"`
Logo string `xorm:"varchar(100)" json:"logo"` Logo string `xorm:"varchar(100)" json:"logo"`
Organization string `xorm:"varchar(100)" json:"organization"` Organization string `xorm:"varchar(100)" json:"organization"`
EnablePassword bool `json:"enablePassword"`
Providers []string `xorm:"varchar(100)" json:"providers"` Providers []string `xorm:"varchar(100)" json:"providers"`
ProviderObjs []*Provider `xorm:"-" json:"providerObjs"` ProviderObjs []*Provider `xorm:"-" json:"providerObjs"`
} }

View File

@ -13,7 +13,7 @@
// limitations under the License. // limitations under the License.
import React from "react"; import React from "react";
import {Button, Card, Col, Input, Row, Select} from 'antd'; import {Button, Card, Col, Input, Row, Select, Switch} from 'antd';
import {LinkOutlined} from "@ant-design/icons"; import {LinkOutlined} from "@ant-design/icons";
import * as ApplicationBackend from "./backend/ApplicationBackend"; import * as ApplicationBackend from "./backend/ApplicationBackend";
import * as Setting from "./Setting"; import * as Setting from "./Setting";
@ -152,6 +152,16 @@ class ApplicationEditPage extends React.Component {
</Select> </Select>
</Col> </Col>
</Row> </Row>
<Row style={{marginTop: '20px'}} >
<Col style={{marginTop: '5px'}} span={2}>
Enable Password:
</Col>
<Col span={1} >
{
<Switch checked={this.state.application.enablePassword} onChange={(checked => {this.updateApplicationField('enablePassword', checked);})} />
}
</Col>
</Row>
<Row style={{marginTop: '20px'}} > <Row style={{marginTop: '20px'}} >
<Col style={{marginTop: '5px'}} span={2}> <Col style={{marginTop: '5px'}} span={2}>
Providers: Providers:

View File

@ -48,6 +48,7 @@ class ApplicationListPage extends React.Component {
createdTime: moment().format(), createdTime: moment().format(),
displayName: `New Application - ${this.state.applications.length}`, displayName: `New Application - ${this.state.applications.length}`,
logo: "https://cdn.jsdelivr.net/gh/casbin/static/img/logo@2x.png", logo: "https://cdn.jsdelivr.net/gh/casbin/static/img/logo@2x.png",
EnablePassword: true,
providers: [], providers: [],
} }
} }

View File

@ -87,6 +87,7 @@ class Face extends React.Component {
<Input <Input
prefix={<UserOutlined className="site-form-item-icon" />} prefix={<UserOutlined className="site-form-item-icon" />}
placeholder="username" placeholder="username"
disabled={!this.getApplicationObj().enablePassword}
/> />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
@ -97,11 +98,14 @@ class Face extends React.Component {
prefix={<LockOutlined className="site-form-item-icon" />} prefix={<LockOutlined className="site-form-item-icon" />}
type="password" type="password"
placeholder="password" placeholder="password"
disabled={!this.getApplicationObj().enablePassword}
/> />
</Form.Item> </Form.Item>
<Form.Item> <Form.Item>
<Form.Item name="remember" valuePropName="checked" noStyle> <Form.Item name="remember" valuePropName="checked" noStyle>
<Checkbox style={{float: "left"}}>Auto login</Checkbox> <Checkbox style={{float: "left"}} disabled={!this.getApplicationObj().enablePassword}>
Auto login
</Checkbox>
</Form.Item> </Form.Item>
<a style={{float: "right"}} href=""> <a style={{float: "right"}} href="">
Forgot password? Forgot password?
@ -113,6 +117,7 @@ class Face extends React.Component {
type="primary" type="primary"
htmlType="submit" htmlType="submit"
style={{width: "100%"}} style={{width: "100%"}}
disabled={!this.getApplicationObj().enablePassword}
> >
Login Login
</Button> </Button>