public FoodMarkerService()
        {
            _tokenPersistance = new TokenPersistanceService();
            _restService      = new RestService();
            _extRestService   = new ExternalRestService();
            TokenHeaderBuilder headerBuilder = new TokenHeaderBuilder(_restService);

            headerBuilder.BuildHeaders();
        }
        public async Task <bool> Login()
        {
            var tokenPersistanceService = new TokenPersistanceService();

            RestReturnObj <UserToken> returnObj =
                await _restService.UserAuthRequest("Login", _userData);

            if (returnObj.IsSuccess)
            {
                string token   = returnObj.Obj.Token;
                bool   success = tokenPersistanceService.SaveToken(token);
                return(success);
            }
            return(false);
        }
示例#3
0
        public async Task <bool> IsValidToken()
        {
            var    tokenService = new TokenPersistanceService();
            string token        = tokenService.GetToken(WebApiCred.KeyChainTokenKey);

            if (string.IsNullOrEmpty(token))
            {
                return(false);
            }
            else
            {
                bool isValid = await _restService.IsTokenValid();

                if (!isValid)
                {
                    tokenService.RemoveToken(WebApiCred.KeyChainTokenKey);
                    return(false);
                }
            }
            return(true);
        }