Skip to content

Instantly share code, notes, and snippets.

@diego3g
Created September 11, 2017 18:08
Show Gist options
  • Save diego3g/619f4404e24b6464ffdc269d24c2ef01 to your computer and use it in GitHub Desktop.
Save diego3g/619f4404e24b6464ffdc269d24c2ef01 to your computer and use it in GitHub Desktop.
// src/services/auth.js
import { AsyncStorage } from 'react-native';
export const TOKEN_KEY = "@RocketSeat:token";
export const onSignIn = () => AsyncStorage.setItem(TOKEN_KEY, "true");
export const onSignOut = () => AsyncStorage.removeItem(TOKEN_KEY);
export const isSignedIn = async () => {
const token = await AsyncStorage.getItem(TOKEN_KEY);
return (token !== null) ? true : false;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment