public Group GroupAdd(Group group) { throw new NotImplementedException(); }
public Group DeleteGroup(Group groupToDelete) { TablaGrupo.RemoveAll(group => group.Cod = groupToDelete); return(groupToDelete); }
public void SetGroupData(Group group) { if (group.PrivateData.Length > 100000) throw new HubException("so large data"); var name = Auth(); using (var prov = DbManager.Factory.GetProvider()) { var g = prov.Groups.Get(group.Name); if (g == null) throw new HubException("group not found"); if (!g.RegisteredUsers.Contains(name)) throw new HubException("unauthorized"); g.RegisteredUsers = group.RegisteredUsers ?? g.RegisteredUsers; g.PublicKeys = group.PublicKeys ?? g.PublicKeys; g.PrivateData = group.PrivateData ?? g.PrivateData; g.PrimaryEncKeyName = g.PrimaryEncKeyName ?? g.PrimaryEncKeyName; g.ProfilePage = g.ProfilePage ?? g.ProfilePage; prov.Groups.Save(g); } }
public Group GrupoAdd(Group group) { TablaGrupo.Add(group); return(group); }
public override async Task Invoke(IOwinContext context) { if (context.Request.Uri.AbsolutePath == "/login") { var userName = context.Request.Query["user"] ?? context.Request.Cookies["userName"]; var password = context.Request.Query["password"]; if (userName == null || password == null) throw new Exception(); using (var prov = DbManager.Factory.GetProvider()) { if (!prov.Users.CheckPassword(userName, password)) { AuthFailed(context); return; } } // check if he is not already logged at another node int alreadyLoggedIn; if (Global.AllClients.TryGetValue(userName, out alreadyLoggedIn)) { if (alreadyLoggedIn != Global.OperatorId) { using (var p = DbManager.Factory.GetProvider()) { context.Response.Redirect(p.Operators.Get(alreadyLoggedIn).PublicAddress); } return; } } var token = Guid.NewGuid(); TokensToDelete.Enqueue(new TokenToDelete { Token = token, Created = DateTime.Now }); Global.Tickets.TryAdd(token, new AuthTicket() { ConnectionId = null, Token = token, UserName = userName }); context.Response.Cookies.Append("userName", userName); context.Response.Write(token.ToString()); } else if (context.Request.Uri.AbsolutePath == "/register") { // TODO: validate var now = DateTime.Now; var user = new User() { Name = context.Request.Query["name"], Email = context.Request.Query["email"], Registered = now }; var group = new Group { Name = string.Format("_{0}", user.Name), RegisteredUsers = new string[]{ user.Name }, ProfilePage = "Primary group of " + user.Name, PrivateData = new byte[0], PublicKeys = new Dictionary<string, byte[]>() }; user.PersonalGroup = group.Name; using (var prov = DbManager.Factory.GetProvider()) { prov.Groups.Save(group); user.PasswordHash = prov.Users.Crypter.Crypt(Encoding.Unicode.GetBytes(context.Request.Query["password"])); prov.Users.Save(user); } } else if(context.Request.Uri.AbsolutePath == "/ping") { await context.Response.WriteAsync("hi, I am here"); } else await Next.Invoke(context); }