public override Group GetGroup(string group) { DataCommand cmd = _catalog.NewQuery(string.Format("SELECT name AS role_name FROM {1}role WHERE name='{0}' LIMIT 1", DataCommand.MakeSqlSafe(group), _prefix)); XDoc role = cmd.ReadAsXDoc("roles", "role"); if (role["role/role_name"].IsEmpty) { return(null); } return(new Group(role["role/role_name"].AsText)); }
public override bool CheckUserPassword(string user, string password) { DataCommand cmd = _catalog.NewQuery(string.Format("SELECT user_pass FROM {1}users WHERE user_login='******' AND user_status=0 LIMIT 1", DataCommand.MakeSqlSafe(user), _prefix)); XDoc result = cmd.ReadAsXDoc("users", "user"); if (result["user"].IsEmpty) { return(false); } string hashed = result["user/user_pass"].AsText; return(CheckPassword(password, hashed)); }
public override Group[] GetGroups() { IList <Group> groupList = new List <Group>(); DataCommand cmd = _catalog.NewQuery(string.Format("SELECT name AS role_name FROM {0}role", _prefix)); XDoc roles = cmd.ReadAsXDoc("roles", "role"); foreach (XDoc role in roles["role/role_name"]) { groupList.Add(new Group(role.AsText)); } Group[] groups = new Group[groupList.Count]; groupList.CopyTo(groups, 0); return(groups); }
public override User GetUser(string user) { string name = "", email = ""; DataCommand cmd = _catalog.NewQuery(string.Format("SELECT username, email, usertype FROM {1}users WHERE username='******' AND block=0 LIMIT 1", DataCommand.MakeSqlSafe(user), _prefix)); XDoc result = cmd.ReadAsXDoc("users", "user"); if (result["user"].IsEmpty) { return(null); } name = result["user/username"].AsText; email = result["user/email"].AsText; Group group = new Group(result["user/usertype"].AsText); return(new User(name, email, new Group[] { group })); }
public override User GetUser(string user) { string name = "", email = ""; DataCommand cmd = _catalog.NewQuery(string.Format("SELECT user_login, user_email FROM {1}users WHERE user_login='******' AND user_status=0 LIMIT 1", DataCommand.MakeSqlSafe(user), _prefix)); XDoc result = cmd.ReadAsXDoc("users", "user"); if (result["user"].IsEmpty) { return(null); } name = result["user/user_login"].AsText; email = result["user/user_email"].AsText; // TODO, group should be determined by deserializing the PHP value in wp_usermeta meta_key='wp_capabilities' return(new User(name, email, new Group[] { _defaultGroup })); }
public override User GetUser(string user) { string name = "", email = ""; Group group = new Group("anonymous user"); DataCommand cmd = _catalog.NewQuery(string.Format("SELECT u.name, u.mail AS email, r.name AS group_name FROM {1}users u LEFT OUTER JOIN {1}users_roles ur ON u.uid=ur.uid LEFT OUTER JOIN {1}role r ON ur.rid=r.rid WHERE u.name='{0}' LIMIT 1", DataCommand.MakeSqlSafe(user), _prefix)); XDoc result = cmd.ReadAsXDoc("users", "user"); if (result["user"].IsEmpty) { return(null); } name = result["user/name"].AsText; email = result["user/email"].AsText; string groupName = result["user/group_name"].AsText; if (!string.IsNullOrEmpty(groupName)) { group = new Group(groupName); } return(new User(name, email, new Group[] { group })); }