示例#1
0
        public async Task <UserStateDTO> GetUserState()
        {
            try
            {
                string s = await storage.GetLocalStorageValue <string>("JWT");

                if (!String.IsNullOrEmpty(s))
                {
                    var user = JsonConvert.DeserializeObject <UserStateDTO>(s);
                    this.http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", user.Token);
                    return(user);
                }

                this.http.DefaultRequestHeaders.Authorization = null;
                return(null);
            }
            catch (Exception ex)
            {
                log.LogException(ex);
                return(null);
            }
        }