Skip to content
This repository has been archived by the owner on Feb 24, 2018. It is now read-only.

CognitoUser constructor uses UserPool's storage #385

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions dist/amazon-cognito-identity.js
Original file line number Diff line number Diff line change
Expand Up @@ -1488,7 +1488,7 @@ return /******/ (function(modules) { // webpackBootstrap
this.signInUserSession = null;
this.authenticationFlowType = 'USER_SRP_AUTH';

this.storage = data.Storage || new _StorageHelper2.default().getStorage();
this.storage = this.pool.getStorage();
}

/**
Expand Down Expand Up @@ -3369,8 +3369,7 @@ return /******/ (function(modules) { // webpackBootstrap

var cognitoUser = {
Username: username,
Pool: _this,
Storage: _this.storage
Pool: _this
};

var returnData = {
Expand All @@ -3396,8 +3395,7 @@ return /******/ (function(modules) { // webpackBootstrap
if (lastAuthUser) {
var cognitoUser = {
Username: lastAuthUser,
Pool: this,
Storage: this.storage
Pool: this
};

return new _CognitoUser2.default(cognitoUser);
Expand All @@ -3406,6 +3404,16 @@ return /******/ (function(modules) { // webpackBootstrap
return null;
};

/**
* This is used to return the storage
* @returns {object} the storage
*/


CognitoUserPool.prototype.getStorage = function getStorage() {
return this.storage;
};

return CognitoUserPool;
}();

Expand Down
4 changes: 2 additions & 2 deletions dist/amazon-cognito-identity.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/amazon-cognito-identity.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ declare module "amazon-cognito-identity-js" {
export interface ICognitoUserData {
Username: string;
Pool: CognitoUserPool;
Storage?: ICognitoStorage;
}

export class CognitoUser {
Expand Down Expand Up @@ -112,6 +111,7 @@ declare module "amazon-cognito-identity-js" {
public signUp(username: string, password: string, userAttributes: CognitoUserAttribute[], validationData: CognitoUserAttribute[], callback: NodeCallback<Error,ISignUpResult>): void;

public getCurrentUser(): CognitoUser | null;
public getStorage(): ICognitoStorage;
}

export interface ICognitoUserSessionData {
Expand Down
2 changes: 1 addition & 1 deletion src/CognitoUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default class CognitoUser {
this.signInUserSession = null;
this.authenticationFlowType = 'USER_SRP_AUTH';

this.storage = data.Storage || new StorageHelper().getStorage();
this.storage = this.pool.getStorage();
}

/**
Expand Down
14 changes: 10 additions & 4 deletions src/CognitoUserPool.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ export default class CognitoUserPool {

const cognitoUser = {
Username: username,
Pool: this,
Storage: this.storage,
Pool: this
};

const returnData = {
Expand All @@ -115,13 +114,20 @@ export default class CognitoUserPool {
if (lastAuthUser) {
const cognitoUser = {
Username: lastAuthUser,
Pool: this,
Storage: this.storage,
Pool: this
};

return new CognitoUser(cognitoUser);
}

return null;
}

/**
* This is used to return the storage
* @returns {object} the storage
*/
getStorage() {
return this.storage;
}
}