private async void getToken() { this.IsRunning = true; if (this.Code.TrimEnd().Equals(token.TrimEnd())) { var tokenUsed = await App.MobileService.GetTable <Reset_Password_Token>().Where(p => p.User_Id_FK == userQuery[0].Id).ToListAsync(); Reset_Password_Token updateTokenInfo = new Reset_Password_Token { Id = tokenUsed[0].Id, IsUsed = true, Token = tokenUsed[0].Token, User_Id_FK = tokenUsed[0].User_Id_FK }; await App.MobileService.GetTable <Reset_Password_Token>().UpdateAsync(updateTokenInfo); this.IsRunning = false; this.Step3 = true; } else { await Application.Current.MainPage.DisplayAlert( "Error", "Invalid Token.", "Accept"); this.IsRunning = false; return; } this.IsRunning = false; this.SecondButton = false; }
private async void sendCode() { this.IsRunning = true; int len = RandomId.length.Next(5, 10); token = RandomId.RandomString(len); userQuery = await App.MobileService.GetTable <User>().Where(p => p.Email == Email).ToListAsync(); if (userQuery.Count > 0) { try { SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); SmtpServer.Port = 587; SmtpServer.Host = "smtp.gmail.com"; SmtpServer.EnableSsl = true; SmtpServer.UseDefaultCredentials = false; SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "leones1234"); SmtpServer.SendAsync("*****@*****.**", this.Email, "Reset Password", "Copy this token and go back to ActivityMaps!: " + token, "xyz123d"); } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Error", ex.Message, "Ok"); } Reset_Password_Token reset = new Reset_Password_Token { Id = RandomId.RandomString(len), Token = token, IsUsed = false, User_Id_FK = userQuery[0].Id }; await App.MobileService.GetTable <Reset_Password_Token>().InsertAsync(reset); this.IsRunning = false; this.Step2 = true; } else { await Application.Current.MainPage.DisplayAlert( "Error", "Invalid Email.", "Accept"); this.IsRunning = false; return; } this.FirstButton = false; }