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

@ -24,11 +24,12 @@ type Application struct {
Name string `xorm:"varchar(100) notnull pk" json:"name"`
CreatedTime string `xorm:"varchar(100)" json:"createdTime"`
DisplayName string `xorm:"varchar(100)" json:"displayName"`
Logo string `xorm:"varchar(100)" json:"logo"`
Organization string `xorm:"varchar(100)" json:"organization"`
Providers []string `xorm:"varchar(100)" json:"providers"`
ProviderObjs []*Provider `xorm:"-" json:"providerObjs"`
DisplayName string `xorm:"varchar(100)" json:"displayName"`
Logo string `xorm:"varchar(100)" json:"logo"`
Organization string `xorm:"varchar(100)" json:"organization"`
EnablePassword bool `json:"enablePassword"`
Providers []string `xorm:"varchar(100)" json:"providers"`
ProviderObjs []*Provider `xorm:"-" json:"providerObjs"`
}
func GetApplications(owner string) []*Application {

View File

@ -13,7 +13,7 @@
// limitations under the License.
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 * as ApplicationBackend from "./backend/ApplicationBackend";
import * as Setting from "./Setting";
@ -152,6 +152,16 @@ class ApplicationEditPage extends React.Component {
</Select>
</Col>
</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'}} >
<Col style={{marginTop: '5px'}} span={2}>
Providers:

View File

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

View File

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