예제 #1
0
        /// <summary>
        /// Save session token using AccountStore
        /// </summary>
        /// <param name="userName">user name</param>
        /// <param name="token">bearer token</param>
        /// <param name="refreshToken">refresh token</param>
        public void SaveToken(string userName, string token, string refreshToken)
        {
            if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(token))
            {
                _token        = token;
                _refreshToken = refreshToken;
                _userName     = userName;
                _save         = true;

                var storageModel = new AuthStorageModel
                {
                    Token        = _token,
                    RefreshToken = _refreshToken,
                    UserName     = _userName,
                    Save         = _save
                };

                _deviceStorageRepository.SaveObj(AuthStorageKey, storageModel);
            }
        }
예제 #2
0
        /// <summary>
        /// Clear saved user session
        /// </summary>
        public void LogOut()
        {
            _token        = null;
            _refreshToken = null;
            _userName     = null;

            if (_save)
            {
                var storageModel = new AuthStorageModel
                {
                    Token        = _token,
                    RefreshToken = _refreshToken,
                    UserName     = _userName,
                    Save         = false
                };

                _deviceStorageRepository.SaveObj(AuthStorageKey, storageModel);
            }

            _save = false;
        }