public dict MakeLoginRequestDict(string publickey) { dict requestDict = new dict(); publickey = publickey.Replace('\n', '*'); requestDict.Add("type", "LOGIN_REQUEST"); requestDict.Add("publickey", publickey); return(requestDict); }
} // activate public dict deactivate(IContext ctx, idstring userid) { dict Return = new dict(); // your code goes here; add return values to 'Return' Return.Add("status", Helpers.Default <bool>()); Return.Add("activationkey", Helpers.Default <varchar>()); return(Return); } // deactivate
public dict MakeTextDict(string userName, string content, string local_ip, string local_name) { dict TextDict = new dict(); TextDict.Add("type", "TEXT_MES"); TextDict.Add("username", Decrypt(userName)); TextDict.Add("content", Decrypt(content)); TextDict.Add("ip", local_ip); TextDict.Add("localname", local_name); return(TextDict); }
} // deactivate public dict get(IContext ctx, idstring userid) { dict Return = new dict(); // your code goes here; add return values to 'Return' Return.Add("status", Helpers.Default <bool>()); Return.Add("realname", Helpers.Default <varchar>()); Return.Add("email", Helpers.Default <email>()); Return.Add("activationkey", Helpers.Default <varchar>()); Return.Add("permissions", Helpers.Default <list>()); return(Return); } // get
} // get public dict grant(IContext ctx, idstring userid, idstring permission) { dict Return = new dict(); // your code goes here; add return values to 'Return' Return.Add("status", Helpers.Default <bool>()); return(Return); } // grant
} // signout public Dictionary <string, object> verify(IContext ctx) { dict Return = new dict(); // your code goes here; add return values to 'Return' Return.Add("status", true); return(Return); } // verify
public dict create(IContext ctx, idstring userid, password password, varchar realname, email email) { dict Return = new dict(); // your code goes here; add return values to 'Return' bool status = false; string message = "unknown error"; long pver; if (userid.str.Length < 5 || !Helpers.IsValidId(userid.str)) { message = "bad user id format: non-special characters, at least length 5 required"; } else if (KeyValueStore.Find("user:"******"the user id " + userid + " already exists"; } else if (KeyValueStore.Find("email:" + email, out pver) != null) { message = "the email address " + email + " is already tied to another user id"; } else { dict user = new dict(); user.Add("userid", userid.str); user.Add("password", password.str); user.Add("realname", realname.str); user.Add("email", email.str); user.Add("activationkey", Helpers.RandomString(24)); if (KeyValueStore.Store("user:"******"user " + userid + " created"; status = true; } else { message = "database error when trying to create user " + userid; } } Return.Add("status", status); Return.Add("message", message); return(Return); } // create
public dict create(IContext ctx, idstring userid, password password, varchar realname, email email) { dict Return = new dict(); // your code goes here; add return values to 'Return' bool status = false; string message = "unknown error"; long pver; if (userid.str.Length < 5 || !Helpers.IsValidId(userid.str)) { message = "bad user id format: non-special characters, at least length 5 required"; } else if (KeyValueStore.Find("user:"******"the user id " + userid + " already exists"; } else if (KeyValueStore.Find("email:" + email, out pver) != null) { message = "the email address " + email + " is already tied to another user id"; } else { dict user = new dict(); user.Add("userid", userid.str); user.Add("password", password.str); user.Add("realname", realname.str); user.Add("email", email.str); user.Add("activationkey", Helpers.RandomString(24)); if (KeyValueStore.Store("user:"******"user " + userid + " created"; status = true; } else { message = "database error when trying to create user " + userid; } } Return.Add("status", status); Return.Add("message", message); return Return; }
public Dictionary <string, object> signin(IContext ctx, idstring userid, password password) { dict Return = new dict(); // your code goes here; add return values to 'Return' if (userid.str != "jwatte" || password.str != "123456") { throw new InvalidOperationException("Bad user name or password."); } UserSession sess = UserSession.Create(ctx, userid.str); Return.Add("token", new idstring(sess.sid)); return(Return); } // signin
public dict MakeLoginDict(String userName, String password, String local_ip, String local_name) { dict LoginDict = new dict(); LoginDict.Add("username", Decrypt(userName)); LoginDict.Add("password", Decrypt(password)); LoginDict.Add("type", "LOGIN_MES"); LoginDict.Add("status", "login"); LoginDict.Add("ip", local_ip); LoginDict.Add("localname", local_name); return(LoginDict); }
public dict MakeRegisterDict(String userName, String password, String local_ip, String local_name) { dict RegisterDict = new dict(); RegisterDict.Add("username", userName); RegisterDict.Add("type", "REGISTER_MES"); RegisterDict.Add("status", "register"); RegisterDict.Add("ip", local_ip); RegisterDict.Add("localname", local_name); RegisterDict.Add("password", password); return(RegisterDict); }
public dict activate(IContext ctx, idstring userid, varchar activationkey) { dict Return = new dict(); // your code goes here; add return values to 'Return' bool status = false; long pver; dict u = KeyValueStore.Find("user:"******"activationkey"].Equals(activationkey.str)) { u["activationkey"] = ""; status = KeyValueStore.Store("user:"******"status", status); return Return; }
} // create public dict activate(IContext ctx, idstring userid, varchar activationkey) { dict Return = new dict(); // your code goes here; add return values to 'Return' bool status = false; long pver; dict u = KeyValueStore.Find("user:"******"activationkey"].Equals(activationkey.str)) { u["activationkey"] = ""; status = KeyValueStore.Store("user:"******"status", status); return(Return); } // activate
public dict get(IContext ctx, idstring userid) { dict Return = new dict(); // your code goes here; add return values to 'Return' Return.Add("status", Helpers.Default<bool>()); Return.Add("realname", Helpers.Default<varchar>()); Return.Add("email", Helpers.Default<email>()); Return.Add("activationkey", Helpers.Default<varchar>()); Return.Add("permissions", Helpers.Default<list>()); return Return; }
public dict deactivate(IContext ctx, idstring userid) { dict Return = new dict(); // your code goes here; add return values to 'Return' Return.Add("status", Helpers.Default<bool>()); Return.Add("activationkey", Helpers.Default<varchar>()); return Return; }
public dict test(IContext ctx, idstring userid, idstring permission) { dict Return = new dict(); // your code goes here; add return values to 'Return' Return.Add("status", Helpers.Default<bool>()); return Return; }