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 { ...@@ -26,11 +26,11 @@ class Component extends PureComponent {
// console.log("currentURL", currentURL) // console.log("currentURL", currentURL)
this.state = { this.state = {
clientId: "6233aedf-f08a-4112-9a1b-f33c3cd9b396", // clientId: "6233aedf-f08a-4112-9a1b-f33c3cd9b396",
clientSecret: "", // clientSecret: "",
redirectURL: currentURL, redirectURL: currentURL,
scopes: "", // scopes: "",
response_type: "token" // response_type: "token"
} }
} }
...@@ -47,9 +47,11 @@ class Component extends PureComponent { ...@@ -47,9 +47,11 @@ class Component extends PureComponent {
updateFieldHandler(field) { updateFieldHandler(field) {
return (e) => { return (e) => {
this.setState({ const upd = {
[field]: e.target.value [field]: e.target.value
}) }
this.props.updateConfig(upd)
// this.setState(upd)
} }
} }
...@@ -59,26 +61,32 @@ class Component extends PureComponent { ...@@ -59,26 +61,32 @@ class Component extends PureComponent {
// console.log("X This state", this.state) // console.log("X This state", this.state)
let authorizationEndpoint = '' let authorizationEndpoint = ''
if (this.state.authorizationEndpoint) { if (this.props.serverConfig) {
authorizationEndpoint = this.state.authorizationEndpoint
} else if (this.props.serverConfig) {
authorizationEndpoint = this.props.serverConfig.authorization_endpoint authorizationEndpoint = this.props.serverConfig.authorization_endpoint
} }
let tokenEndpoint = '' let tokenEndpoint = ''
if (this.state.tokenEndpoint) { if (this.props.serverConfig) {
tokenEndpoint = this.state.tokenEndpoint
} else if (this.props.serverConfig) {
tokenEndpoint = this.props.serverConfig.token_endpoint tokenEndpoint = this.props.serverConfig.token_endpoint
} }
let userinfoEndpoint = '' let userinfoEndpoint = ''
if (this.state.userinfoEndpoint) { if (this.props.serverConfig) {
userinfoEndpoint = this.state.userinfoEndpoint
} else if (this.props.serverConfig) {
userinfoEndpoint = this.props.serverConfig.userinfo_endpoint 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 let expanded = this.props.expanded && !!this.props.serverConfig
return ( return (
...@@ -86,12 +94,12 @@ class Component extends PureComponent { ...@@ -86,12 +94,12 @@ class Component extends PureComponent {
<form> <form>
<h4>OAuth Authorization endpoint</h4> <h4>OAuth Authorization endpoint</h4>
<FormGroup> <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> </FormGroup>
<h4>OAuth Token endpoint</h4> <h4>OAuth Token endpoint</h4>
<FormGroup> <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> </FormGroup>
<h4>Userinfo Endpoint</h4> <h4>Userinfo Endpoint</h4>
...@@ -101,17 +109,18 @@ class Component extends PureComponent { ...@@ -101,17 +109,18 @@ class Component extends PureComponent {
<h4>Client ID</h4> <h4>Client ID</h4>
<FormGroup> <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> </FormGroup>
{/*
<h4>Client secret</h4> <h4>Client secret</h4>
<FormGroup> <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> </FormGroup>
*/}
<h4>Scopes</h4> <h4>Scopes</h4>
<FormGroup> <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>
<FormGroup controlId="response_type"> <FormGroup controlId="response_type">
......
...@@ -11,7 +11,7 @@ const mapStateToProps = (state) => ({ ...@@ -11,7 +11,7 @@ const mapStateToProps = (state) => ({
const mapDispatchToProps = { const mapDispatchToProps = {
authenticateStart: API.authenticate, authenticateStart: API.authenticate,
logoutStart: API.logout, logoutStart: API.logout,
updateConfig: actions.discovery.completed updateConfig: actions.serverConfig.save
} }
const Controller = connect( 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