public void CreateAccountTest() { Credentials c = new Credentials("testUserLogin", Security.ComputeHash("testUserPass")); UserContents uc = new UserContents(c, "Test User", "*****@*****.**"); guiConn.AddUser(uc); Assert.AreEqual(guiConn.GetUser(c), uc); }
public bool AddUser(UserContents u) { var cl = new Ref.FileSyncModelClient(); try { bool result = false; result = cl.AddUser(u); cl.Close(); return result; } catch (Exception ex) { cl.Abort(); throw new ActionException("Unable to create new user account.", ActionType.User, ex); } }
private UserContents getUser() { UserContents u = new UserContents(this.getLogin(), Security.ComputeHash(this.UserPassword.Password), this.UserFullName.Text, this.UserEmail.Text); return u; }
public bool AddUser(UserContents u) { throw new NotImplementedException(); }
public bool AddUser(UserContents u) { using (filesyncEntitiesNew context = new filesyncEntitiesNew()) { if (LoginExists(context, u.Login)) { //throw new Exception("user already exists"); return false; } else { //TODO: don't use password directly User u1 = User.CreateUser(1, u.Login, u.Password); u1.user_email = u.Email; u1.user_fullname = u.Name; u1.user_lastlogin = DateTime.Now; context.Users.AddObject(u1); context.SaveChanges(); } } return true; }
public UserIdentity GetUser(Credentials c) { using (filesyncEntitiesNew context = new filesyncEntitiesNew()) { if (LoginExists(context, c.Login)) { if (Authenticate(context, c)) { int id = LoginToId(context, c.Login); User u1 = (from o in context.Users where o.user_id == id select o).SingleOrDefault(); UserIdentity u = new UserContents(u1.user_login, u1.user_pass, u1.user_fullname, u1.user_email); u.LastLogin = (DateTime)u1.user_lastlogin; u.Id = u1.user_id; return u; } else { //throw new Exception("wrong password"); return null; } } else { //throw new Exception("no such user"); return null; } } }
public UserContents(UserContents uc) : this((UserIdentity)uc, uc.Machines) { //nothing needed here }
private void buttonLogout_Click(object sender, RoutedEventArgs e) { LoggedIn = false; credentials = null; user = null; machine = null; }
private void buttonLoginCreate_Click(object sender, RoutedEventArgs e) { LoginWindow loginWin = new LoginWindow(this); loginWin.Owner = this; if (loginWin.ShowDialog() == true) { if (this.credentials == null) return; try { this.user = connection.GetUserWithMachines(credentials); //new UserContents(credentials, true); LoggedIn = true; if (this.machine == null) buttonCreateSelectMachine_Click(sender, e); else RefreshDisplayedMachineInfo(); } catch (ActionException ex) { new SystemMessage(ex).ShowDialog(); //MessageBox.Show(ex.Message, ex.Title); } } }
public void GetMachineList(Credentials c, UserContents u) { throw new Exception("not implemented"); }
public void AddUser(Credentials c, UserContents u) { throw new Exception("not implemented"); }