public override string[] GetRolesForUser(string username) { FoireMusesConnection connection = new FoireMusesConnection(new XUri(Configuration.ApiUrl + ":" + Configuration.ApiPort + "/" + Configuration.ApiAt), Configuration.ApiUsername, Configuration.ApiPassword); try { User user = connection.GetUser(username, new Result<User>()).Wait(); if (user.IsAdmin) return new string[] { "ADMIN", "MEMBER" }; else return new string[] { "MEMBER" }; } catch (Exception e) { return new string[] { }; } }
public override bool ValidateUser(string username, string password) { FoireMusesConnection connection = new FoireMusesConnection(new XUri(Configuration.ApiUrl + ":" + Configuration.ApiPort + "/" + Configuration.ApiAt), Configuration.ApiUsername, Configuration.ApiPassword); try { User user = connection.GetUser(username, new Result<User>()).Wait(); if (user == null) return false; if (user.Password != password) return false; return true; } catch (Exception e) { return false; } }
public override bool IsUserInRole(string username, string roleName) { if (roleName == "MEMBER") return true; FoireMusesConnection connection = new FoireMusesConnection(new XUri(Configuration.ApiUrl + ":" + Configuration.ApiPort + "/" + Configuration.ApiAt), Configuration.ApiUsername, Configuration.ApiPassword); try { User user = connection.GetUser(username, new Result<User>()).Wait(); if (user.IsAdmin) return true; return false; } catch (Exception e) { return false; } }