Exemplo n.º 1
0
 public async Task <IBaseResponse> LoginAsync(IModelAuthDetails auth)
 {
     return(new BaseResponse()
     {
         IsOk = true
     });
 }
Exemplo n.º 2
0
        public async Task <IBaseResponse> RegisterStoreOwner(IModelAuthDetails auth)
        {
            BaseResponse response = new BaseResponse();

            var a = new FirebaseAuthProvider(new FirebaseConfig(AuthKey));

            try
            {
                var authLink = await a.CreateUserWithEmailAndPasswordAsync(auth.Username, auth.Password, auth.Username, false);

                response.IsOk     = true;
                response.Message  = "RegisterStoreOwner";
                response.Response = authLink.FirebaseToken;
                response.Attributes.Add("token", authLink.FirebaseToken);
                response.Attributes.Add("localid", authLink.User.LocalId);
            }
            catch (FirebaseAuthException ex)
            {
                string json = ex.ResponseData;
                var    fbr  = (FirebaseResponse)JsonConvert.DeserializeObject <FirebaseResponse>(json);
                response.IsOk     = false;
                response.Response = fbr.error.message;
            }

            return(response);
        }
Exemplo n.º 3
0
        public async Task <IBaseResponse> LoginAsync(IModelAuthDetails auth)
        {
            BaseResponse response = new BaseResponse();

            var a = new FirebaseAuthProvider(new FirebaseConfig(AuthKey));

            try
            {
                var authLink = await a.SignInWithEmailAndPasswordAsync(auth.Username, auth.Password);

                response.IsOk     = true;
                response.Message  = "CreateStoreAccount";
                response.Response = authLink.FirebaseToken;
                response.Attributes.Add("token", authLink.FirebaseToken);
                response.Attributes.Add("localid", authLink.User.LocalId);
            }
            catch (FirebaseAuthException ex)
            {
                string json = ex.ResponseData.TrimStart().TrimEnd();
                response.IsOk = false;

                if (!string.IsNullOrEmpty(json) && json.StartsWith("{") && json.EndsWith("}"))
                {
                    var fbr = (FirebaseResponse)JsonConvert.DeserializeObject <FirebaseResponse>(json);
                    response.Message  = fbr.error.message;
                    response.Response = fbr.error;
                }
            }

            return(response);
        }
Exemplo n.º 4
0
 public Task <IBaseResponse> RegisterStoreOwner(IModelAuthDetails auth)
 {
     throw new System.NotImplementedException();
 }