Commit 9daf0245 authored by Varun Patil's avatar Varun Patil

Use webview for login

parent 6350dbcb
<html>
<body>
<table>
<tr>
<td>
Hello World<br>
<a href="https://gymkhana.iitb.ac.in/sso/account/login/?next=/sso/oauth/authorize/%3Fclient_id%3DvR1pU7wXWyve1rUkg0fMS6StL1Kr6paoSmRIiLXJ%26response_type%3Dcode%26scope%3Dbasic%2520profile%2520picture%2520sex%2520ldap%2520phone%2520insti_address%2520program%2520secondary_emails%26redirect_uri=https://redirecturi">
:LOGIN:
</a>
</td>
</tr>
</table>
</body>
</html>
\ No newline at end of file
...@@ -19,6 +19,9 @@ import android.support.v4.content.LocalBroadcastManager; ...@@ -19,6 +19,9 @@ import android.support.v4.content.LocalBroadcastManager;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.webkit.WebResourceRequest;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button; import android.widget.Button;
import android.widget.Toast; import android.widget.Toast;
...@@ -58,6 +61,7 @@ public class LoginActivity extends AppCompatActivity { ...@@ -58,6 +61,7 @@ public class LoginActivity extends AppCompatActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
session = new SessionManager(mContext); session = new SessionManager(mContext);
setContentView(R.layout.activity_login); setContentView(R.layout.activity_login);
mAuthService = new AuthorizationService(this); mAuthService = new AuthorizationService(this);
...@@ -140,6 +144,34 @@ public class LoginActivity extends AppCompatActivity { ...@@ -140,6 +144,34 @@ public class LoginActivity extends AppCompatActivity {
@Override @Override
protected void onStart() { protected void onStart() {
super.onStart(); super.onStart();
WebView webview = (WebView) findViewById(R.id.login_webview);
webview.loadUrl("file:///android_asset/login.html");
webview.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
/* Capture redirect */
if (url.startsWith(redirectUri.toString())) {
/* Show progress dialog */
progressDialog = new ProgressDialog(LoginActivity.this);
progressDialog.setMessage("Logging In");
progressDialog.setCancelable(false);
progressDialog.setIndeterminate(true);
progressDialog.show();
/* Get auth code from query */
String query = Uri.parse(url).getQuery();
authCode = query.substring(query.lastIndexOf("=") + 1);
login(authCode, redirectUri.toString(), authCode);
return true;
}
/* Load URL */
view.loadUrl(url);
return false;
}
});
checkIntent(getIntent()); checkIntent(getIntent());
} }
......
...@@ -19,5 +19,11 @@ ...@@ -19,5 +19,11 @@
android:layout_gravity="center" android:layout_gravity="center"
android:text="LDAP login" /> android:text="LDAP login" />
<WebView
android:id="@+id/login_webview"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</WebView>
</LinearLayout> </LinearLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment