public MainWindow() { InitializeComponent(); _authService = new AuthServiceClient(); _doctorService = new DoctorServiceClient(new InstanceContext(new DoctorHandler(null))); _patientService = new PatientServiceClient(new InstanceContext(new PatientHandler())); }
public void UndeleteMission(int missionID, string author, string password) { var db = new ZkDataContext(); var prev = db.Missions.Where(x => x.MissionID == missionID).SingleOrDefault(); if (prev != null) { var acc = AuthServiceClient.VerifyAccountPlain(author, password); if (acc == null) { Trace.TraceWarning("Invalid login attempt for {0}", author); System.Threading.Thread.Sleep(new Random().Next(2000)); throw new ApplicationException("Cannot verify user account"); } if (acc.AccountID != prev.AccountID && acc.AdminLevel < AdminLevel.Moderator) { throw new ApplicationException("You cannot undelete a mission from an other user"); } prev.IsDeleted = false; db.SaveChanges(); } else { throw new ApplicationException("No such mission found"); } }
public ActionResult ChangePassword(string oldPassword, string newPassword, string newPassword2) { var db = new ZkDataContext(); var acc = db.Accounts.Find(Global.AccountID); if (acc == null) { return(Content("Invalid accountID")); } if (string.IsNullOrEmpty(acc.PasswordBcrypt)) { return(Content("Your account is password-less, use steam")); } if (AuthServiceClient.VerifyAccountPlain(acc.Name, oldPassword) == null) { Trace.TraceWarning("Failed password check for {0} on attempted password change", Global.Account.Name); Global.Server.LoginChecker.LogIpFailure(Request.UserHostAddress); return(Content("Invalid password")); } if (newPassword != newPassword2) { return(Content("New passwords do not match")); } if (string.IsNullOrWhiteSpace(newPassword)) { return(Content("New password cannot be blank")); } acc.SetPasswordPlain(newPassword); db.SaveChanges(); //return Content("Old: " + oldPassword + "; new: " + newPassword); return(RedirectToAction("Logout", "Home")); }
public AccountInfo GetAccountInfo(string login, string password) { var acc = AuthServiceClient.VerifyAccountPlain(login, password); if (acc == null) { return(null); } else { return new AccountInfo() { Name = acc.Name, Country = acc.Country, Aliases = acc.Aliases, ZeroKAccountID = acc.AccountID, ZeroKLevel = acc.Level, ClanID = acc.ClanID ?? 0, ClanName = acc.Clan != null ? acc.Clan.ClanName : null, IsZeroKAdmin = acc.IsZeroKAdmin, Avatar = acc.Avatar, Elo = (float)acc.Elo, EffectiveElo = acc.EffectiveElo, EloWeight = (float)acc.EloWeight, FactionID = acc.FactionID ?? 0, FactionName = acc.Faction != null ? acc.Faction.Name : null, SpringieLevel = acc.GetEffectiveSpringieLevel(), LobbyID = acc.LobbyID ?? 0 } }; }
public ActionResult Login(FormCollection collection) { using (ServiceHelper serviceHelper = new ServiceHelper()) { try { LoginViewModel lvm = new LoginViewModel { Username = Convert.ToString(collection["Username"]), Password = Convert.ToString(collection["Password"]) }; AuthServiceClient authClient = serviceHelper.GetAuthServiceClient(); if (authClient.Login(lvm.Username, lvm.Password)) { AuthHelper.Login(lvm); lvm.Id = serviceHelper.GetCustomerServiceClient().FindCustomerByUsername(lvm.Username).Id; } else { throw new InvalidLoginException(); } return(RedirectToAction("Index", "Home")); } catch { return(View()); } } }
private void btnLogin_Click(object sender, RoutedEventArgs e) { Debug.Print("Login Click"); string username = this.txtUsername.Text; string password = this.txtPassword.Password; //verify login AuthService.AuthServiceClient client = new AuthServiceClient(); VerifyUserResponse response = client.VerifyUser(new VerifyUserRequest(username, password)); if (response.VerifyUserResult.success) { ClearMessageLabel(); //transition to main form NavigationService.GetNavigationService(this).Navigate(new Dashboard()); } else { SetMessageLabel("Invalid Username/Password Combination"); } }
public async Task <ActionResult> Login(LoginViewModel model) { if (ModelState.IsValid) { using (AuthServiceClient client = new AuthServiceClient()) { UserDTO userDTO = new UserDTO { Email = model.Email, Password = model.Password }; ClaimsIdentity claim = await Task.Run(() => client.Authenticate(userDTO)); if (claim == null) { ModelState.AddModelError("", "Incorrect password or login"); } else { AuthMng.SignOut(); AuthMng.SignIn(new AuthenticationProperties { IsPersistent = true }, claim); return(RedirectToAction("Index", "Home")); } } } return(View(model)); }
/// <summary> /// Atualizar a descrição de um utilizador /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnSetDescription_Click(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; Application.DoEvents(); using (AuthServiceClient service = new AuthServiceClient()) { string login = txtLogin.Text; string password = txtPassword.Text; string description = txtMyDescription.Text; bool result = service.SetUserDescription(login, password, description); if (result) { MessageBox.Show("A descrição foi atualizada com sucesso."); } else { MessageBox.Show("Ocorreu um erro ao atualizar a descrição"); } } // lembrar de usar o "using" } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { this.Cursor = Cursors.Default; } }
private void submit_login(object sender, RoutedEventArgs e) { var client = new AuthServiceClient(); string email = txt_email.Text; string password = txt_password.Password.ToString(); try { string token = client.LoginUser(email, password); if (!string.IsNullOrEmpty(token)) { Application.Current.Resources["Token"] = token; //create main window and dispose current one MainWindow main = new MainWindow(); main.Show(); this.Close(); } else { lbl_error.Content = "Invalid email or password"; } } catch (Exception) { } finally { client.Close(); } }
public ActionResult Index() { if (Request[GlobalConst.ASmallCakeCookieName] != null) { return(RedirectToAction("Index", new {})); } var db = new ZkDataContext(); var result = new IndexResult() { Spotlight = SpotlightHandler.GetRandom(), Top10Players = db.Accounts.Where(x => x.SpringBattlePlayers.Any(y => y.SpringBattle.StartTime > DateTime.UtcNow.AddMonths(-1))).OrderByDescending( x => x.Elo1v1).Take(10) }; result.LobbyStats = AuthServiceClient.GetLobbyStats(); result.News = db.News.Where(x => x.Created < DateTime.UtcNow).OrderByDescending(x => x.Created); if (Global.Account != null) { result.Headlines = db.News.Where( x => x.Created <DateTime.UtcNow && x.HeadlineUntil != null && x.HeadlineUntil> DateTime.UtcNow && (Global.Account.LastNewsRead == null || (x.Created > Global.Account.LastNewsRead))). OrderByDescending(x => x.Created); if (result.Headlines.Any()) { db.Accounts.Single(x => x.AccountID == Global.AccountID).LastNewsRead = DateTime.UtcNow; db.SubmitChanges(); } } else { result.Headlines = new List <News>(); } var accessibleThreads = db.ForumThreads.Where(x => x.RestrictedClanID == null || x.RestrictedClanID == Global.ClanID); if (!Global.IsAccountAuthorized) { result.NewThreads = accessibleThreads.OrderByDescending(x => x.LastPost).Take(10).Select(x => new NewThreadEntry() { ForumThread = x }); } else { result.NewThreads = (from t in accessibleThreads let read = t.ForumThreadLastReads.SingleOrDefault(x => x.AccountID == Global.AccountID) where read == null || t.LastPost > read.LastRead orderby t.LastPost descending select new NewThreadEntry { ForumThread = t, WasRead = read != null, WasWritten = read != null && read.LastPosted != null }). Take(10); } return(View(result)); }
/// <summary> /// Obter a lista de utilizadores /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnGetUsers_Click(object sender, EventArgs e) { using (AuthServiceClient service = new AuthServiceClient()) { var users = service.GetUsers(txtLogin.Text, txtPassword.Text); if (users != null) { lboxUsers.DataSource = users; lboxUsers.DisplayMember = "Name"; lboxUsers.ValueMember = "Login"; } else { MessageBox.Show("Something went wrong while getting users."); lboxUsers.DataSource = null; } } //// versão 1 //lboxUsers.DataSource = users; //lboxUsers.DisplayMember = "Name"; //lboxUsers.ValueMember = "Login"; //// versão 2 //lboxUsers.Items.Clear(); //foreach (User user in users) //{ // lboxUsers.Items.Add(user.Login); //} }
public void MovePlayers(string autohostName, string autohostPassword, List <MovePlayerEntry> moves) { var db = new ZkDataContext(); var acc = AuthServiceClient.VerifyAccountPlain(autohostName, autohostPassword); if (acc == null) { throw new Exception("Invalid password"); } var name = autohostName.TrimNumbers(); var entry = db.AutohostConfigs.SingleOrDefault(x => x.Login == name); if (entry == null) { throw new Exception("Not an autohost"); } try { foreach (var m in moves) { Global.Nightwatch.Tas.ForceJoinBattle(m.PlayerName, m.BattleHost); } } catch (Exception ex) { Trace.TraceError("Error while moving players: {0}", ex); } }
static void Main(string[] args) { if (!Directory.Exists(Settings.Default.ExportPath)) { Console.WriteLine(string.Format("Export path doesn't exist : {0}", Settings.Default.ExportPath)); return; } _url = Settings.Default.ApiUrl; _startDate = DateTime.Now.Subtract(TimeSpan.FromDays(1)); _endDate = DateTime.Now; try { var auth = new AuthServiceClient(_url, null, null, null, null); var response = auth.Authenticate(Settings.Default.Username, Settings.Default.Password); response.Wait(); _token = response.Result; } catch { Console.WriteLine(string.Format("Verify your admin credentials, user {0} and password {1} are invalid", Settings.Default.Username, Settings.Default.Password)); return; } ExportOrders(); }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { using (AuthServiceClient client = new AuthServiceClient()) { RegisDTO regisDTO = new RegisDTO { Email = model.Email, Password = model.Password, Role = "customer", Address = model.Address, City = model.City, PostalCode = model.PostalCode, FirstName = model.FirstName, LastName = model.LastName, StateProvinceID = model.State }; OperationDetails operationDetails = await Task.Run(() => client.Register(regisDTO)); if (operationDetails.Status == OperationDetails.Statuses.Success) { return(RedirectToAction("Index", "Home")); } else { ModelState.AddModelError(operationDetails.Status.ToString(), operationDetails.Message); } } } return(View(model)); }
protected void ButtonRegister_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.TextBoxRegisterUserName.Text) || string.IsNullOrEmpty(this.TextBoxRegisterPassword.Text)) { MessageBox.Show("Please provide username and password"); } else { var client = new AuthServiceClient(); var adminModel = new AdminModel { AdminUserName = TextBoxRegisterUserName.Text, AdminPassword = TextBoxRegisterPassword.Text }; bool result = Convert.ToBoolean(client.RegisterAdmin(adminModel)); if (result) { LabelMSG.Text = "You have been registered"; } else { LabelMSG.Text = "Admin already exists"; } } }
static void Main(string[] args) { Configure(); //authClient = new AuthServiceClient("NetTcpBinding_IAuthService"); authClient = new AuthServiceClient("WSHttpBinding_IAuthService"); //secureClient = new SecureServiceClient("NetTcpBinding_ISecureUserService"); secureClient = new SecureUserServiceClient("WSHttpBinding_ISecureUserService"); Tuple <string, string> usernamepw = PromptUserNamePassword(); Login(usernamepw.Item1, usernamepw.Item2); if (IsUserLoggedIn) { GetDataWithValidCredentials(usernamepw.Item1, usernamepw.Item2); } else { Console.WriteLine("User credentials not valid"); } Console.ReadLine(); }
public virtual void Setup() { var authResponseTask = new AuthServiceClient(BaseUrl, null, new DummyPackageInfo(), null, null) .Authenticate(TestAccount.Email, TestAccountPassword); authResponseTask.Wait(); SessionId = authResponseTask.Result.SessionId; }
public bool VerifyUser(string UserName, string Password) { int _cim = int.Parse(UserName); // Use User Verification Service AuthServiceClient authService = new AuthServiceClient(); return(authService.Authenticate(_cim, Password)); }
public bool VerifyUser(string UserName, string Password) { int _cim = int.Parse(UserName); // Use User Verification Service AuthServiceClient authService = new AuthServiceClient(); return authService.Authenticate(_cim, Password); }
void MvcApplication_PostAuthenticateRequest(object sender, EventArgs e) { if (DateTime.UtcNow.Subtract(lastPollCheck).TotalMinutes > 15) { PollController.AutoClosePolls(); lastPollCheck = DateTime.UtcNow; } Account acc = null; if (Request[GlobalConst.ASmallCakeCookieName] != null) { var testAcc = Account.AccountByName(new ZkDataContext(), Request[GlobalConst.ASmallCakeLoginCookieName]); if (testAcc != null) { if (AuthTools.ValidateSiteAuthToken(testAcc.Name, testAcc.Password, Request[GlobalConst.ASmallCakeCookieName])) { acc = testAcc; } } } if (acc == null) { if (Request[GlobalConst.LoginCookieName] != null) { acc = AuthServiceClient.VerifyAccountHashed(Request[GlobalConst.LoginCookieName], Request[GlobalConst.PasswordHashCookieName]); } } if (acc != null) { var ip = GetUserIP(); using (var db = new ZkDataContext()) { var penalty = Punishment.GetActivePunishment(acc.AccountID, ip, null, x => x.BanSite, db); if (penalty != null) { Response.Write(string.Format("You are banned! (IP match to account {0})\n", penalty.AccountByAccountID.Name)); Response.Write(string.Format("Ban expires: {0} UTC\n", penalty.BanExpires)); Response.Write(string.Format("Reason: {0}\n", penalty.Reason)); Response.End(); } else { HttpContext.Current.User = acc; // todo replace with safer permanent cookie Response.SetCookie(new HttpCookie(GlobalConst.LoginCookieName, acc.Name) { Expires = DateTime.Now.AddMonths(12) }); Response.SetCookie(new HttpCookie(GlobalConst.PasswordHashCookieName, acc.Password) { Expires = DateTime.Now.AddMonths(12) }); } } } }
public async void when_user_sign_in() { var sut = new AuthServiceClient(BaseUrl, null, new DummyPackageInfo(), null, null); var response = await sut.Authenticate(TestAccount.Email, TestAccountPassword); Assert.IsNotNull(response); Assert.IsNotNull(response.SessionId, "Test"); Assert.AreEqual(TestAccount.Email, response.UserName); }
public bool VerifyAccountData(string login, string password) { var acc = AuthServiceClient.VerifyAccountPlain(login, password); if (acc == null) { return(false); } return(true); }
public HttpResponseMessage Auth(string uporabnikID) { AuthServiceClient authService = new AuthServiceClient(); DAuth dAuth = authService.GetSession(uporabnikID); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, dAuth); return(response); }
public HttpResponseMessage Auth(string uporabnikID, string apl) { AuthServiceClient authService = new AuthServiceClient(); DAplRoles roles = authService.GetApplicationRoles(uporabnikID, apl); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, roles); return(response); }
public HttpResponseMessage Boolean(string sessionToken) { AuthServiceClient authService = new AuthServiceClient(); DSessionValid sessionValid = authService.IsSessionValid(sessionToken); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, sessionValid); return(response); }
/// <summary> /// Creates an IAccessTokenProvider with the supplied test credentials. /// </summary> /// <param name="httpClient">The httpClient that makes the request to the auth server</param> /// <param name="tokenProvisioningEndpoint">The auth server</param> /// <param name="keyId">The id of the security token</param> /// <param name="rsaParameters">The public and private key for the supplied key id</param> /// <returns>An IAccessTokenProvider with the supplied test credentials</returns> public static IAccessTokenProvider Create(HttpClient httpClient, String tokenProvisioningEndpoint, Guid keyId, RSAParameters rsaParameters) { #pragma warning disable 618 IPrivateKeyProvider privateKeyProvider = new StaticPrivateKeyProvider(keyId, rsaParameters); #pragma warning restore 618 ITokenSigner tokenSigner = new TokenSigner(privateKeyProvider); IAuthServiceClient authServiceClient = new AuthServiceClient(httpClient, new Uri(tokenProvisioningEndpoint)); INonCachingAccessTokenProvider noCacheTokenProvider = new AccessTokenProvider(tokenSigner, authServiceClient); return(new CachedAccessTokenProvider(noCacheTokenProvider, Timeout.InfiniteTimeSpan)); }
private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) { AuthServiceClient authClient = new AuthServiceClient(); String sessionId = (String)App.Current.Properties[App.sessionPropertyName]; if (authClient.Logout(sessionId)) { App.Current.Properties[App.sessionPropertyName] = null; App.Current.Properties[App.loginPropertyName] = null; } }
public async void when_user_sign_in_with_twitter() { var account = await GetNewTwitterAccount(); var sut = new AuthServiceClient(BaseUrl, null, new DummyPackageInfo(), null, null); var response = await sut.AuthenticateTwitter(account.TwitterId); Assert.IsNotNull(response); Assert.IsNotNull(response.SessionId, "Test"); Assert.AreEqual(account.TwitterId, response.UserName); }
public JsonResult GetData() { if (Session["_user"] != null) { var scClient = new AuthServiceClient(); user v = scClient.GetData((int)Session["_user"]); Json(v); return Json(v, JsonRequestBehavior.AllowGet); } return null; }
public UserContract Login(string userName, string password) { AuthServiceClient client = new AuthServiceClient(); UserContract retUser = client.Login(userName, password); client.Close(); if (retUser != null) { CreateCookie(userName, true); } return(retUser); }
private async Task <IAccessToken> RunTestHelper(HttpClient mockClient) { IAuthServiceClient client = new AuthServiceClient( httpClient: mockClient, authEndpoint: new Uri(TEST_URI) ); return(await client.ProvisionAccessTokenAsync( assertion : string.Empty, scopes : new Scope[] {} )); }
public void SplitAutohost(BattleContext context, string password) { if (AuthServiceClient.VerifyAccountPlain(context.AutohostName, password) == null) { throw new Exception("Invalid password"); } if (context.GetConfig() == null) { throw new Exception("Not an autohost"); } Balancer.SplitAutohost(context); }
public UserContract CreateUser(UserContract user) { AuthServiceClient client = new AuthServiceClient(); var createdUser = client.CreateUser(user); client.Close(); if (createdUser != null) { CreateCookie(createdUser.UserName, true); return(createdUser); } return(null); }
public JsonResult Login(Qz.GPS.DirectService.Parameter.User.Login user) { SsoService.AuthServiceClient auth = new AuthServiceClient(); var token = auth.Login(user.Account, user.Password); return Json( new Qz.Core.Entity.Response() { Message = token } ); }
protected void Page_Load(object sender, EventArgs e) { var userId = Request.QueryString["u"]; var transferId = Request.QueryString["tid"]; var token = Request.QueryString["tkn"]; ServiceReference1.AuthServiceClient c = new AuthServiceClient(); c.ClientCredentials.UserName.UserName = "******"; c.ClientCredentials.UserName.Password = "******"; var newSessionId = c.ValidateTransfer("", userId, transferId, token); if (newSessionId != null) { lbl.Text = "Successfully Authenticated <br/>" + userId + " + " + newSessionId; } }
private void btnChangePassword_Click(object sender, RoutedEventArgs e) { //verify all fields are filled out string username = this.txtUsername.Text; string oldPassword = this.txtOldPassword.Password; string newPassword = this.txtNewPassword.Password; string confirmPassword = this.txtConfirmPassword.Password; if (String.IsNullOrWhiteSpace(username)) { SetMessageLabel("Username cannot be blank."); return; } if (String.IsNullOrWhiteSpace(oldPassword)) { SetMessageLabel("Current password cannot be blank"); } AuthService.AuthServiceClient client = new AuthServiceClient(); ChangePasswordResponse response = client.ChangePassword(new ChangePasswordRequest(username, oldPassword, newPassword, confirmPassword)); //if successfully, go back if (response.ChangePasswordResult.success) { ClearMessageLabel(); NavigationService.GetNavigationService(this).GoBack(); } else { SetMessageLabel("Change Password failed"); } //if not, display error message }
/// <summary> /// Users authentication service to get auth key /// </summary> /// <param name="sender"></param> /// <param name="args"></param> void GetAuthenticationKey(object sender, DoWorkEventArgs args) { var credentials = args.Argument as Credentials; try { var client = new AuthServiceClient(); args.Result = client.GetAuthKey(credentials.Username, credentials.Password); client.Close(); } catch (EndpointNotFoundException e) { args.Result = String.Empty; } }
public CnBBAL.AuthenticationService.EmployeeDetails GetEmployeeDetails(int CimNumber) { AuthServiceClient authService = new AuthServiceClient(); return authService.GetEmployee(CimNumber); }