Commit 3c6a3f2e authored by Andreas Åkre Solberg's avatar Andreas Åkre Solberg

Let ServerConfig update using actions global state.

parent 748bbc12
Pipeline #3733 passed with stages
in 7 minutes and 41 seconds
......@@ -26,11 +26,11 @@ class Component extends PureComponent {
// console.log("currentURL", currentURL)
this.state = {
clientId: "6233aedf-f08a-4112-9a1b-f33c3cd9b396",
clientSecret: "",
// clientId: "6233aedf-f08a-4112-9a1b-f33c3cd9b396",
// clientSecret: "",
redirectURL: currentURL,
scopes: "",
response_type: "token"
// scopes: "",
// response_type: "token"
}
}
......@@ -47,9 +47,11 @@ class Component extends PureComponent {
updateFieldHandler(field) {
return (e) => {
this.setState({
const upd = {
[field]: e.target.value
})
}
this.props.updateConfig(upd)
// this.setState(upd)
}
}
......@@ -59,26 +61,32 @@ class Component extends PureComponent {
// console.log("X This state", this.state)
let authorizationEndpoint = ''
if (this.state.authorizationEndpoint) {
authorizationEndpoint = this.state.authorizationEndpoint
} else if (this.props.serverConfig) {
if (this.props.serverConfig) {
authorizationEndpoint = this.props.serverConfig.authorization_endpoint
}
let tokenEndpoint = ''
if (this.state.tokenEndpoint) {
tokenEndpoint = this.state.tokenEndpoint
} else if (this.props.serverConfig) {
if (this.props.serverConfig) {
tokenEndpoint = this.props.serverConfig.token_endpoint
}
let userinfoEndpoint = ''
if (this.state.userinfoEndpoint) {
userinfoEndpoint = this.state.userinfoEndpoint
} else if (this.props.serverConfig) {
if (this.props.serverConfig) {
userinfoEndpoint = this.props.serverConfig.userinfo_endpoint
}
let clientId = ''
if (this.props.serverConfig) {
clientId = this.props.serverConfig.client_id
}
let clientSecret = ''
let scopes = ''
if (this.props.serverConfig) {
scopes = this.props.serverConfig.scopes
}
let expanded = this.props.expanded && !!this.props.serverConfig
return (
......@@ -86,12 +94,12 @@ class Component extends PureComponent {
<form>
<h4>OAuth Authorization endpoint</h4>
<FormGroup>
<FormControl type="text" value={authorizationEndpoint} onChange={this.updateFieldHandler.bind(this)("authorizationEndpoint")} />
<FormControl type="text" value={authorizationEndpoint} onChange={this.updateFieldHandler.bind(this)("authorization_endpoint")} />
</FormGroup>
<h4>OAuth Token endpoint</h4>
<FormGroup>
<FormControl type="text" value={tokenEndpoint} onChange={this.updateFieldHandler.bind(this)("tokenEndpoint")} />
<FormControl type="text" value={tokenEndpoint} onChange={this.updateFieldHandler.bind(this)("token_endpoint")} />
</FormGroup>
<h4>Userinfo Endpoint</h4>
......@@ -101,17 +109,18 @@ class Component extends PureComponent {
<h4>Client ID</h4>
<FormGroup>
<FormControl type="text" bsSize="large" value={this.state.clientId} onChange={this.updateFieldHandler.bind(this)("clientId")} />
<FormControl type="text" bsSize="large" value={clientId} onChange={this.updateFieldHandler.bind(this)("client_id")} />
</FormGroup>
{/*
<h4>Client secret</h4>
<FormGroup>
<FormControl type="text" bsSize="large" value={this.state.clientSecret} onChange={this.updateFieldHandler.bind(this)("clientSecret")} />
<FormControl type="text" bsSize="large" value={clientSecret} onChange={this.updateFieldHandler.bind(this)("client_secret")} />
</FormGroup>
*/}
<h4>Scopes</h4>
<FormGroup>
<FormControl type="text" bsSize="large" value={this.state.scopes} onChange={this.updateFieldHandler.bind(this)("scopes")} />
<FormControl type="text" bsSize="large" value={scopes} onChange={this.updateFieldHandler.bind(this)("scopes")} />
</FormGroup>
<FormGroup controlId="response_type">
......
......@@ -11,7 +11,7 @@ const mapStateToProps = (state) => ({
const mapDispatchToProps = {
authenticateStart: API.authenticate,
logoutStart: API.logout,
updateConfig: actions.discovery.completed
updateConfig: actions.serverConfig.save
}
const Controller = connect(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment