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

Add save serverconfig.

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