Commit c56692f7 authored by Andreas Åkre Solberg's avatar Andreas Åkre Solberg

Add save serverconfig.

parent a3d5b009
......@@ -6167,6 +6167,11 @@
"reduce-reducers": "0.1.2"
}
},
"redux-localstorage": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/redux-localstorage/-/redux-localstorage-0.4.1.tgz",
"integrity": "sha1-+vbXGcWBOXKU2BFHP/zt7gZckzw="
},
"redux-promise": {
"version": "0.5.3",
"resolved": "https://registry.npmjs.org/redux-promise/-/redux-promise-0.5.3.tgz",
......
......@@ -12,13 +12,15 @@ class Component extends PureComponent {
console.log("--- props", this.props)
this.state = {
clientId: "6233aedf-f08a-4112-9a1b-f33c3cd9b396",
clientSecret: "af85a0f0-2c68-421d-8228-a6c83628de19"
clientSecret: "af85a0f0-2c68-421d-8228-a6c83628de19",
redirectURL: "http://localhost:8080/callback"
}
}
authenticateStart() {
console.error("Authenticate")
let config = Object.assign({}, this.props.serverConfig, this.state)
console.error("Authenticate", config)
this.props.authenticateStart(config)
}
......@@ -76,7 +78,7 @@ class Component extends PureComponent {
<h4>Redirect URI</h4>
<p>When you configure your client, please register the following redirect uri:</p>
<p><code>http://localhost:8080/callback</code></p>
<p><code>{this.state.redirectURL}</code></p>
<div>
<Button onClick={this.authenticateStart.bind(this)} bsStyle="primary">
......
......@@ -37,6 +37,8 @@ let store = createStore(
)
)
store.dispatch(API.callback())
// const state = store.getState()
// if (!state.auth.user.token) {
// const token = appJso.checkToken()
......
......@@ -17,6 +17,12 @@ const reducer = handleActions({
serverConfig: action.payload
}
}
},
serverConfig: {
save: (config) => ({
serverConfig: config.serverConfig,
serverError: null
})
}
},
{
......
import actions from '../actions/'
import jso from '../../lib/jso'
// console.error("actions", actions)
let appJSO = null
const API = {
......@@ -36,10 +37,33 @@ const API = {
"authenticate": function(config) {
return dispatch => {
console.error("About to save config", config)
console.error("About to save config", JSON.stringify(config, undefined, 3))
dispatch(actions.serverConfig.save(config))
console.error("About to authentication")
const jsoconfig = {
providerID: "oauthPlay",
client_id: config.clientId,
redirect_uri: config.redirectURL,
authorization: config.authorization_endpoint
// scopes: { request: ["userinfo"]}
}
setTimeout(() => {
console.error("JSOCONFIG", JSON.stringify(jsoconfig, undefined, 2))
appJSO = new jso(jsoconfig)
appJSO.getToken((token) => {
console.error("Got token, ayay", token)
})
}, 1000)
}
},
"callback": function() {
return (dispatch, getState) => {
var state = getState()
console.error("Callback", state)
// appJSO.callback()
}
}
......
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