Skip to content

Commit 69d208d

Browse files
committed
forgot to deserialize stored state
1 parent 59d5af4 commit 69d208d

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

‎src/OidcClientService.js‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import SignoutRequest from './SignoutRequest';
77
import SignoutResponse from './SignoutResponse';
88
import WebStorageStateStore from './WebStorageStateStore';
99
import ResponseValidator from './ResponseValidator';
10+
import State from './State';
1011

1112
export default class OidcClientService {
1213
// logging
@@ -96,12 +97,14 @@ export default class OidcClientService {
9697

9798
var stateKey = response.state;
9899

99-
return this._stateStore.remove(stateKey).then(state => {
100-
if (!state){
100+
return this._stateStore.remove(stateKey).then(storedStateString => {
101+
if (!storedStateString){
101102
Log.error("No matching state found in storage");
102103
throw new Error("No matching state found in storage");
103104
}
104105

106+
let state = State.fromStorageString(storedStateString);
107+
105108
Log.info("Received state from storage; validating response");
106109
return this._validator.validateSigninResponse(state, response);
107110
});

‎test/OidcClientService.spec.js‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import SigninResponse from '../src/SigninResponse';
44
import ErrorResponse from '../src/ErrorResponse';
55
import SignoutRequest from '../src/SignoutRequest';
66
import SignoutResponse from '../src/SignoutResponse';
7+
import State from '../src/State';
78

89
import Log from '../src/Log';
910

@@ -205,10 +206,13 @@ describe("OidcClientService", function() {
205206
});
206207
});
207208

208-
it("should call validator", function(done) {
209-
stubStore.item = "state";
210-
subject.processSigninResponse("state=state").then(response => {
211-
stubValidator.signinState.should.equal('state');
209+
it("should deserialize stored state and call validator", function(done) {
210+
211+
stubStore.item = new State({id:'1', nonce:'2'}).toStorageString();
212+
213+
subject.processSigninResponse("state=1").then(response => {
214+
stubValidator.signinState.id.should.equal('1');
215+
stubValidator.signinState.nonce.should.equal('2');
212216
stubValidator.signinResponse.should.be.deep.equal(response);
213217
done();
214218
});

0 commit comments

Comments
 (0)