import * as utils from './utils';

const tokenSvc = {
    getToken() {
        var authToken = sessionStorage.getItem('authToken');
        if(authToken == null){
            return null;
        }
                
        var tokenArr = authToken.split('.');

        var jwtToken = utils.base64decode(tokenArr[1]);
        return JSON.parse(jwtToken);
    },
    removeToken() {       
        delete sessionStorage.authToken;
    },
     
    setAuthToken(token){
        sessionStorage.authToken =  token;
    },
    getAuthToken(){
        var authToken = sessionStorage.authToken;
        return authToken;
    }
};

export default tokenSvc;
