Clean up comments

This commit is contained in:
Kyle Corbelli 2017-09-27 15:08:29 -07:00
parent 1bc7520928
commit 1c67ec2e3a
3 changed files with 5 additions and 26 deletions

View File

@ -1,9 +1,3 @@
// import { AsyncStorage } from 'react-native'
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Rip this out into its own npm package:
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const AsyncLocalStorage = {
getItem: (key: string): Promise<any> => new Promise((resolve, reject) => {
try {
@ -72,8 +66,3 @@ const AsyncLocalStorage = {
}
export default AsyncLocalStorage
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ^ Rip this out into its own npm package
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -40,11 +40,11 @@ import {
import AsyncLocalStorage from './AsyncLocalStorage'
import {
deleteAuthHeaders,
deleteAuthHeadersFromLocalStorage,
deleteAuthHeadersFromDeviceStorage,
getUserAttributesFromResponse,
persistAuthHeadersInDeviceStorage,
setAuthHeaders,
} from './services/auth' // <- maybe this is where you pass in the platform paramter, specifying if it is for a browser or for React Native
} from './services/auth'
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Pure Redux actions:
@ -146,10 +146,9 @@ const generateAuthActions = (config: { [key: string]: any }): ActionsExport => {
data,
})
setAuthHeaders(response.headers)
// Have to check what type of platform it is, depending on the key provided by the end-user... like "browser", "iphone", or "android", etc.:
persistAuthHeadersInDeviceStorage(Storage, response.headers)
const userAttributesToSave = getUserAttributesFromResponse(userAttributes, response)
dispatch(registrationRequestSucceeded(userAttributesToSave)) // <- need to make this reducer more flexible
dispatch(registrationRequestSucceeded(userAttributesToSave))
} catch (error) {
dispatch(registrationRequestFailed())
throw error
@ -167,7 +166,6 @@ const generateAuthActions = (config: { [key: string]: any }): ActionsExport => {
params: verificationParams,
})
setAuthHeaders(response.headers)
// Have to check what type of platform it is, depending on the key provided by the end-user... like "browser", "iphone", or "android", etc.:
persistAuthHeadersInDeviceStorage(Storage, response.headers)
const userAttributesToSave = getUserAttributesFromResponse(userAttributes, response)
dispatch(verifyTokenRequestSucceeded(userAttributesToSave))
@ -194,7 +192,6 @@ const generateAuthActions = (config: { [key: string]: any }): ActionsExport => {
},
})
setAuthHeaders(response.headers)
// Have to check what type of platform it is, depending on the key provided by the end-user... like "browser", "iphone", or "android", etc.:
persistAuthHeadersInDeviceStorage(Storage, response.headers)
const userAttributesToSave = getUserAttributesFromResponse(userAttributes, response)
dispatch(signInRequestSucceeded(userAttributesToSave))
@ -218,8 +215,7 @@ const generateAuthActions = (config: { [key: string]: any }): ActionsExport => {
data: userSignOutCredentials,
})
deleteAuthHeaders()
// Have to check what type of platform it is, depending on the key provided by the end-user... like "browser", "iphone", or "android", etc.:
deleteAuthHeadersFromLocalStorage(Storage)
deleteAuthHeadersFromDeviceStorage(Storage)
dispatch(signOutRequestSucceeded())
} catch (error) {
dispatch(signOutRequestFailed())
@ -228,7 +224,6 @@ const generateAuthActions = (config: { [key: string]: any }): ActionsExport => {
}
const verifyCredentials = async (store: Store<{}>): Promise<void> => {
// Gotta check what the platform is:
if (await Storage.getItem('access-token')) {
const verificationParams: VerificationParams = {
'access-token': await Storage.getItem('access-token') as string,

View File

@ -21,9 +21,7 @@ export const setAuthHeaders = (headers: AuthHeaders): void => {
})
}
// Will have to take a parameter from the package user to determine if this is for a browser or for React Native:
export const persistAuthHeadersInDeviceStorage = (Storage: DeviceStorage, headers: AuthHeaders): void => {
// use multiSet:
authHeaderKeys.forEach((key: string) => {
Storage.setItem(key, headers[key])
})
@ -35,12 +33,9 @@ export const deleteAuthHeaders = (): void => {
})
}
// Will have to take a parameter from the package user to determine if this is for a browser or for React Native:
export const deleteAuthHeadersFromLocalStorage = async (Storage: DeviceStorage): Promise<void> => {
// can use multiRemove once you've written it:
export const deleteAuthHeadersFromDeviceStorage = async (Storage: DeviceStorage): Promise<void> => {
authHeaderKeys.forEach((key: string) => {
Storage.removeItem(key)
// localStorage.removeItem(key)
})
}