Commit 7008f93a authored by Daniel Puchala's avatar Daniel Puchala
Browse files

feat: moved userAuth type to file types.ts

parent a874eac4
......@@ -2,3 +2,12 @@ export enum MovieCardMode {
LandingPage,
Recommend
}
export interface UserAuth {
exp: number,
iat: number,
iss: string,
name: string,
role: string,
sub: number
}
import instance from '../models/axios';
import jwtDecode from 'jwt-decode';
import { UserAuth } from '../models/types';
export const login = async (name: string, password: string) => {
try {
......@@ -17,7 +18,7 @@ export const logout = () => {
sessionStorage.removeItem('user');
}
export const getToken = () => {
export const getToken = (): string => {
const user = sessionStorage.getItem('user');
return user ? JSON.parse(user) : null;
}
......@@ -27,11 +28,3 @@ export const getUser = (): UserAuth | null => {
return user ? jwtDecode(JSON.parse(user)) : null;
}
interface UserAuth {
exp: number,
iat: number,
iss: string,
name: string,
role: string,
sub: number
}
Supports Markdown
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