Beispiel #1
0
        public async Task <TaskResult> ConnectUser(Models.UserModel user)
        {
            HttpResponseMessage rsp = await customHttpClient.performRequest(DejaMobileHttpClient.Request.logUser, user);

            if (rsp.StatusCode == System.Net.HttpStatusCode.OK)
            {
                string json = await DejaMobileHttpClient.getJsonFromHttpResponse(rsp);

                Models.AuthJwtModel authJwt = JsonConvert.DeserializeObject <Models.AuthJwtModel>(json);
                onUserConnected(user, authJwt.token);
                return(new TaskResult(TaskResult.TaskName.logUser, true, TaskResult.TaskStatus.finished, null, "User successfully connected"));
            }
            else
            {
                onUserNotConnected();
                return(new TaskResult(TaskResult.TaskName.logUser, false, TaskResult.TaskStatus.finished, null, "ERROR while connecting user : " + rsp.StatusCode.ToString()));
            }
        }
Beispiel #2
0
        public async Task <TaskResult> CreateUser(Models.UserModel user)
        {
            try
            {
                HttpResponseMessage rsp = await customHttpClient.performRequest(DejaMobileHttpClient.Request.createUser, user);

                if (rsp.StatusCode == System.Net.HttpStatusCode.Created)
                {
                    return(new TaskResult(TaskResult.TaskName.createUser, true, TaskResult.TaskStatus.finished, null, "User successfully created"));
                }
                else
                {
                    return(new TaskResult(TaskResult.TaskName.createUser, false, TaskResult.TaskStatus.finished, null, "ERROR while creating user : "******"ERROR internal SDK exception while processing CREATE USER request"));
            }
        }
Beispiel #3
0
 //TODO remove
 public void injectThisToken(Models.UserModel user, string token)
 {
     customHttpClient.storeAuthJwt(user, token);
     status = true;
 }
Beispiel #4
0
 private void onUserConnected(Models.UserModel currentUser, string token)
 {
     status           = true;
     this.currentUser = currentUser;
     customHttpClient.storeAuthJwt(currentUser, token);
 }
Beispiel #5
0
 public void storeAuthJwt(Models.UserModel currentUser, string jwt)
 {
     httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", jwt);
     this.jwt         = jwt;
     this.currentUser = currentUser;
 }