Skip to content

Commit

Permalink
Untested push
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaison Titus committed Sep 7, 2017
1 parent d3627bd commit d4cb73c
Show file tree
Hide file tree
Showing 20 changed files with 502 additions and 649 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import io.hasura.sdk.Hasura;
import io.hasura.sdk.HasuraClient;
import io.hasura.sdk.ProjectConfig;
import io.hasura.sdk.authProvider.MobileAuthProvider;
import io.hasura.sdk.authProvider.UsernameAuthProvider;
import io.hasura.sdk.exception.HasuraInitException;
import io.hasura.sdk.HasuraUser;
import io.hasura.sdk.responseListener.AuthResponseListener;
Expand Down Expand Up @@ -83,13 +85,24 @@ protected void onCreate(Bundle savedInstanceState) {
Log.i(TAG, "Logged in present: " + user.toString());
ToDoActivity.startActivity(this);
}
user.setMobile("8861503583");


}

private void signUp() {
user.setUsername(username.getText().toString());
user.setPassword(password.getText().toString());
user.signUp(new SignUpResponseListener() {
MobileAuthProvider.sendOtp("adsad", new MobileAuthProvider.OtpStatusListener() {
@Override
public void onOtpSentSuccessfully() {
//
}

@Override
public void onFailure(HasuraException e) {

}
});

user.signUp(new UsernameAuthProvider(username.getText().toString(), password.getText().toString()), new SignUpResponseListener() {
@Override
public void onSuccessAwaitingVerification(HasuraUser user) {

Expand All @@ -109,9 +122,7 @@ public void onFailure(HasuraException e) {
}

private void login() {
user.setUsername(username.getText().toString());
user.setPassword(password.getText().toString());
user.login(new AuthResponseListener() {
user.login(new UsernameAuthProvider(username.getText().toString(), password.getText().toString()),new AuthResponseListener() {
@Override
public void onSuccess(String message) {
ToDoActivity.startActivity(AuthenticationActivity.this);
Expand All @@ -122,10 +133,8 @@ public void onFailure(HasuraException e) {
handleError(e);
}
});

}


@Override
public void onClick(View v) {
switch (v.getId()) {
Expand Down
20 changes: 16 additions & 4 deletions sdk/src/main/java/io/hasura/sdk/HasuraClient.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package io.hasura.sdk;

import com.google.gson.Gson;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import io.hasura.sdk.authProvider.EmailAuthProvider;
import io.hasura.sdk.authProvider.MobileAuthProvider;
import io.hasura.sdk.query.HasuraQuery;
import io.hasura.sdk.responseListener.FileDownloadResponseListener;
import io.hasura.sdk.service.CustomService;
import io.hasura.sdk.service.EmailAuthProviderAPIService;
import io.hasura.sdk.service.HasuraFileService;
import io.hasura.sdk.service.MobileAuthProviderAPIService;
import okhttp3.*;
import okhttp3.logging.HttpLoggingInterceptor;

Expand Down Expand Up @@ -63,6 +65,18 @@ private HasuraClient(Builder builder) {
.shouldEnableLogging(builder.shouldEnableLogs)
.build();

OkHttpClient.Builder anonymousClientBuilder = new OkHttpClient.Builder();
if (this.shouldEnableLogs) {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
anonymousClientBuilder.addInterceptor(logging);
}

//Setting the apiService for the different providers
OkHttpClient anonymousClient = anonymousClientBuilder.build();
EmailAuthProvider.setApiService(new EmailAuthProviderAPIService(projectConfig.getAuthUrl(), anonymousClient));
MobileAuthProvider.setApiService(new MobileAuthProviderAPIService(projectConfig.getAuthUrl(), anonymousClient));

//update the user with saved data
HasuraSessionStore.updateUserWithSavedData(this.currentUser);
}
Expand Down Expand Up @@ -102,8 +116,6 @@ public HasuraUser getUser() {
return currentUser;
}

/**************************************DATA SERVICE*********************************************/

private HasuraTokenInterceptor getTokenInterceptorForRole(String role) {
if (interceptorRoleMap.containsKey(role)) {
return interceptorRoleMap.get(role);
Expand Down
Loading

0 comments on commit d4cb73c

Please sign in to comment.