private void DoRegister(object sender, EventArgs e) { if (Functions.IsOffline()) { ResponseManager.ShowMessage("Error", "No internet connection!"); return; } if (_txtPassword.Text != _txtPassword2.Text) { ResponseManager.ShowMessage("Error", "Passwords do not match!"); return; } ResponseManager.ShowLoading("Creating account..."); var data = new NameValueCollection(); data.Add("register", string.Empty); data.Add("email", _txtEmail.Text); data.Add("password", Functions.GetSha256(_txtPassword.Text)); data.Add("firstname", _txtFirstName.Text); data.Add("lastname", _txtLastName.Text); data.Add("class", _txtClass.Text); string reply = WebFunctions.Request(data); ResponseManager.DismissLoading(); if (reply != "Account created!") { ResponseManager.ShowMessage("Error", reply); WebFunctions.ClearCookies(); return; } RunOnUiThread(delegate { var dialogFragment = new DialogFragment(); dialogFragment.InitializeOk(reply, "Success", delegate { Intent resultData = new Intent(); resultData.PutExtra("email", _txtEmail.Text); resultData.PutExtra("password", _txtPassword.Text); SetResult(Result.Ok, resultData); Finish(); }); dialogFragment.Show(); }); }
private void DoLogin(object sender, EventArgs e) { if (Functions.IsOffline()) { ResponseManager.ShowMessage("Error", "No internet connection!"); return; } ResponseManager.ShowLoading("Logging in..."); var data = new NameValueCollection(); data.Add("login", string.Empty); data.Add("email", _txtEmail.Text); data.Add("password", Functions.GetSha256(_txtPassword.Text)); string reply = WebFunctions.Request(data); if (reply != "Login success!") { ResponseManager.DismissLoading(); ResponseManager.ShowMessage("Error", reply); WebFunctions.ClearCookies(); return; } data.Clear(); data.Add("getaccounttype", string.Empty); reply = WebFunctions.Request(data); if (reply != "student" && reply != "teacher") { ResponseManager.DismissLoading(); ResponseManager.ShowMessage("Error", "Unrecognized account type!"); WebFunctions.ClearCookies(); return; } Functions.SaveSetting("settings", "accountType", reply); Functions.SaveSetting("settings", "loggedIn", "true"); StartActivity(typeof(MainActivity)); Finish(); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); Functions.CurrentContext = this; Functions.DeleteSetting("signedInCookie"); Functions.DeleteSetting("settings", "loggedIn"); WebFunctions.ClearCookies(); SetContentView(Resource.Layout.Login); _btnLogin = FindViewById <Button> (Resource.Id.btnLogin); _txtEmail = FindViewById <EditText> (Resource.Id.txtEmail); _txtPassword = FindViewById <EditText> (Resource.Id.txtPassword); _lblRegister = FindViewById <TextView> (Resource.Id.lblRegister); _btnLogin.Click += btnLogin_OnClick; _lblRegister.Click += btnRegister_OnClick; }