mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-20 20:59:00 +00:00
Fix registration. Fixes #117
This commit is contained in:
parent
46cb3f5275
commit
ceaf3086e2
5 changed files with 40 additions and 11 deletions
|
|
@ -171,18 +171,16 @@ public class APIHelper implements ErrorHandler, Profiler {
|
|||
this.apiService.postTaskDirection(id, direction.toString(), callback);
|
||||
}
|
||||
|
||||
public void registerUser(View btnClicked, String username, String email, String password, String confirmPassword) {
|
||||
|
||||
// ATAskRegisterUser reg = new ATAskRegisterUser(mResultListener,mConfig,btnClicked);
|
||||
// String[] params = {username,email,password,confirmPassword};
|
||||
// reg.execute(params);
|
||||
|
||||
public void registerUser(String username, String email, String password, String confirmPassword, Callback<UserAuthResponse> callback) {
|
||||
UserAuth auth = new UserAuth();
|
||||
auth.setUsername(username);
|
||||
auth.setPassword(password);
|
||||
auth.setConfirmPassword(confirmPassword);
|
||||
auth.setEmail(email);
|
||||
this.apiService.registerUser(auth, callback);
|
||||
}
|
||||
|
||||
public void connectUser(String username, String password, Callback<UserAuthResponse> callback) {
|
||||
// ATaskConnectUser con = new ATaskConnectUser(mResultListener,mConfig,btnClicked);
|
||||
// String[] params = {username,password};
|
||||
// con.execute(params);
|
||||
UserAuth auth = new UserAuth();
|
||||
auth.setUsername(username);
|
||||
auth.setPassword(password);
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ public class LoginActivity extends AppCompatActivity
|
|||
showValidationError(R.string.login_validation_error_fieldsmissing);
|
||||
return;
|
||||
}
|
||||
mApiHelper.registerUser(v,username,email,password,cpassword);
|
||||
mApiHelper.registerUser(username,email,password, cpassword, LoginActivity.this);
|
||||
} else {
|
||||
String username,password;
|
||||
username = String.valueOf(mUsernameET.getText());
|
||||
|
|
|
|||
|
|
@ -83,6 +83,9 @@ public interface ApiService {
|
|||
@DELETE("/user/tags/{id}")
|
||||
void deleteTag(@Path("id") String id, Callback<Void> voidCallback);
|
||||
|
||||
@POST("/register")
|
||||
void registerUser(@Body UserAuth auth, Callback<UserAuthResponse> callback);
|
||||
|
||||
@POST("/user/auth/local")
|
||||
void connectLocal(@Body UserAuth auth, Callback<UserAuthResponse> callback);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ package com.magicmicky.habitrpgwrapper.lib.models;
|
|||
public class UserAuth {
|
||||
private String username;
|
||||
private String password;
|
||||
private String confirmPassword;
|
||||
private String email;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
|
|
@ -22,4 +24,16 @@ public class UserAuth {
|
|||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getConfirmPassword() {
|
||||
return confirmPassword;
|
||||
}
|
||||
|
||||
public void setConfirmPassword(String confirmPassword) {
|
||||
this.confirmPassword = confirmPassword;
|
||||
}
|
||||
|
||||
public String getEmail() { return email; }
|
||||
|
||||
public void setEmail(String email) { this.email = email; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,17 +4,31 @@ package com.magicmicky.habitrpgwrapper.lib.models;
|
|||
* Created by magicmicky on 04/02/15.
|
||||
*/
|
||||
public class UserAuthResponse {
|
||||
//we need apiToken and token, as both are possible returns
|
||||
private String apiToken;
|
||||
private String token;
|
||||
private String id;
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
if (this.token == null) {
|
||||
return this.apiToken;
|
||||
} else {
|
||||
return this.token;
|
||||
}
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public String getApiToken() {
|
||||
return apiToken;
|
||||
}
|
||||
|
||||
public void setApiToken(String apiToken) {
|
||||
this.apiToken = apiToken;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue