Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7612


Ignore:
Timestamp:
03/13/12 17:28:04 (12 years ago)
Author:
ascheibe
Message:

#1648

  • added a ws method for resetting a password
  • added user role checking for the service
Location:
branches/ClientUserManagement
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/ClientUserManagement/HeuristicLab.Clients.Access.Views/3.3/UserViews/ChangePasswordDialog.cs

    r7611 r7612  
    4646        MessageBox.Show("Couldn't fetch user information from the server." + Environment.NewLine + "Please verify that you have an existing user and that your user name and password is correct. ", "HeuristicLab Access Service", MessageBoxButtons.OK, MessageBoxIcon.Error);
    4747      } else {
    48         bool result = AccessClient.CallAccessService<bool>(x => x.ResetPassword(UserInformation.Instance.User.Id, oldPasswordTextBox.Text, newPasswordTextBox.Text));
     48        bool result = AccessClient.CallAccessService<bool>(x => x.ChangePassword(UserInformation.Instance.User.Id, oldPasswordTextBox.Text, newPasswordTextBox.Text));
    4949        if (result) {
    5050          MessageBox.Show("Password change successfull.", "HeuristicLab Access Service", MessageBoxButtons.OK, MessageBoxIcon.Information);
  • branches/ClientUserManagement/HeuristicLab.Clients.Access/3.3/ServiceClients/AccessServiceClient.cs

    r7611 r7612  
    1111namespace HeuristicLab.Clients.Access {
    1212
    13 
    14   [System.Diagnostics.DebuggerStepThroughAttribute()]
    15   [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
    16   [System.Runtime.Serialization.DataContractAttribute(Name = "UserGroupBase", Namespace = "http://schemas.datacontract.org/2004/07/HeuristicLab.Services.Access.DataTransfer" +
    17       "")]
    18   [System.SerializableAttribute()]
    19   [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Access.UserGroup))]
    20   [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Access.User))]
    21   [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Access.LightweightUser))]
    22   public partial class UserGroupBase : HeuristicLab.Clients.Access.AccessItem {
    23 
    24     [System.Runtime.Serialization.OptionalFieldAttribute()]
    25     private System.Guid IdField;
    26 
    27     [System.Runtime.Serialization.DataMemberAttribute()]
    28     public System.Guid Id {
    29       get {
    30         return this.IdField;
    31       }
    32       set {
    33         if ((this.IdField.Equals(value) != true)) {
    34           this.IdField = value;
    35           this.RaisePropertyChanged("Id");
    36         }
    37       }
    38     }
    39   }
    4013
    4114  [System.Diagnostics.DebuggerStepThroughAttribute()]
     
    7346
    7447    public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
     48
     49
    7550  }
    7651
     
    680655          this.TimestampField = value;
    681656          this.RaisePropertyChanged("Timestamp");
     657        }
     658      }
     659    }
     660  }
     661
     662  [System.Diagnostics.DebuggerStepThroughAttribute()]
     663  [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
     664  [System.Runtime.Serialization.DataContractAttribute(Name = "UserGroupBase", Namespace = "http://schemas.datacontract.org/2004/07/HeuristicLab.Services.Access.DataTransfer" +
     665      "")]
     666  [System.SerializableAttribute()]
     667  [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Access.UserGroup))]
     668  [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Access.User))]
     669  [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Access.LightweightUser))]
     670  public partial class UserGroupBase : HeuristicLab.Clients.Access.AccessItem {
     671
     672    [System.Runtime.Serialization.OptionalFieldAttribute()]
     673    private System.Guid IdField;
     674
     675    [System.Runtime.Serialization.DataMemberAttribute()]
     676    public System.Guid Id {
     677      get {
     678        return this.IdField;
     679      }
     680      set {
     681        if ((this.IdField.Equals(value) != true)) {
     682          this.IdField = value;
     683          this.RaisePropertyChanged("Id");
    682684        }
    683685      }
     
    10591061  public interface IAccessService {
    10601062
     1063    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IAccessService/RemoveUserGroupBaseFromGroup", ReplyAction = "http://tempuri.org/IAccessService/RemoveUserGroupBaseFromGroupResponse")]
     1064    void RemoveUserGroupBaseFromGroup(HeuristicLab.Clients.Access.UserGroupBase resource, HeuristicLab.Clients.Access.UserGroup group);
     1065
    10611066    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IAccessService/GetUsersAndGroups", ReplyAction = "http://tempuri.org/IAccessService/GetUsersAndGroupsResponse")]
    10621067    System.Collections.Generic.List<HeuristicLab.Clients.Access.UserGroupBase> GetUsersAndGroups();
     
    12001205    void RemoveUserFromRole(HeuristicLab.Clients.Access.Role role, HeuristicLab.Clients.Access.User user);
    12011206
     1207    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IAccessService/ChangePassword", ReplyAction = "http://tempuri.org/IAccessService/ChangePasswordResponse")]
     1208    bool ChangePassword(System.Guid userId, string oldPassword, string newPassword);
     1209
    12021210    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IAccessService/ResetPassword", ReplyAction = "http://tempuri.org/IAccessService/ResetPasswordResponse")]
    1203     bool ResetPassword(System.Guid userId, string oldPassword, string newPassword);
     1211    string ResetPassword(System.Guid userId);
    12041212
    12051213    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IAccessService/GetAllUserGroups", ReplyAction = "http://tempuri.org/IAccessService/GetAllUserGroupsResponse")]
     
    12231231    [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IAccessService/AddUserGroupBaseToGroup", ReplyAction = "http://tempuri.org/IAccessService/AddUserGroupBaseToGroupResponse")]
    12241232    void AddUserGroupBaseToGroup(HeuristicLab.Clients.Access.UserGroupBase resource, HeuristicLab.Clients.Access.UserGroup group);
    1225 
    1226     [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IAccessService/RemoveUserGroupBaseFromGroup", ReplyAction = "http://tempuri.org/IAccessService/RemoveUserGroupBaseFromGroupResponse")]
    1227     void RemoveUserGroupBaseFromGroup(HeuristicLab.Clients.Access.UserGroupBase resource, HeuristicLab.Clients.Access.UserGroup group);
    12281233  }
    12291234
     
    12551260    }
    12561261
     1262    public void RemoveUserGroupBaseFromGroup(HeuristicLab.Clients.Access.UserGroupBase resource, HeuristicLab.Clients.Access.UserGroup group) {
     1263      base.Channel.RemoveUserGroupBaseFromGroup(resource, group);
     1264    }
     1265
    12571266    public System.Collections.Generic.List<HeuristicLab.Clients.Access.UserGroupBase> GetUsersAndGroups() {
    12581267      return base.Channel.GetUsersAndGroups();
     
    14431452    }
    14441453
    1445     public bool ResetPassword(System.Guid userId, string oldPassword, string newPassword) {
    1446       return base.Channel.ResetPassword(userId, oldPassword, newPassword);
     1454    public bool ChangePassword(System.Guid userId, string oldPassword, string newPassword) {
     1455      return base.Channel.ChangePassword(userId, oldPassword, newPassword);
     1456    }
     1457
     1458    public string ResetPassword(System.Guid userId) {
     1459      return base.Channel.ResetPassword(userId);
    14471460    }
    14481461
     
    14741487      base.Channel.AddUserGroupBaseToGroup(resource, group);
    14751488    }
    1476 
    1477     public void RemoveUserGroupBaseFromGroup(HeuristicLab.Clients.Access.UserGroupBase resource, HeuristicLab.Clients.Access.UserGroup group) {
    1478       base.Channel.RemoveUserGroupBaseFromGroup(resource, group);
    1479     }
    14801489  }
    14811490}
  • branches/ClientUserManagement/HeuristicLab.Services.Access/3.3/AccessService.cs

    r7611 r7612  
    3636    private IUserManager UserManager {
    3737      get {
    38         if (userManager == null) userManager = new UserManager();
     38        if (userManager == null) userManager = AccessServiceLocator.Instance.UserManager;
    3939        return userManager;
    4040      }
     
    4444    private IRoleVerifier RoleVerifier {
    4545      get {
    46         if (roleVerifier == null) roleVerifier = new RoleVerifier();
     46        if (roleVerifier == null) roleVerifier = AccessServiceLocator.Instance.RoleVerifier;
    4747        return roleVerifier;
    4848      }
     
    143143
    144144    public void DeleteClient(DT.Client client) {
     145      roleVerifier.AuthenticateForAllRoles(AccessServiceRoles.Administrator);
     146
    145147      using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {
    146148        //load client because we could get a detached object
     
    198200
    199201    public void DeleteClientGroup(DT.ClientGroup clientGroup) {
     202      roleVerifier.AuthenticateForAllRoles(AccessServiceRoles.Administrator);
     203
    200204      using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {
    201205        //load clientGroup because we could get a detached object
     
    289293
    290294    public void DeleteClientLog(DT.ClientLog log) {
     295      roleVerifier.AuthenticateForAllRoles(AccessServiceRoles.Administrator);
     296
    291297      using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {
    292298        context.ClientLogs.DeleteOnSubmit(Convert.ToEntity(log));
     
    484490
    485491    public DT.User AddUser(DT.User user) {
     492      roleVerifier.AuthenticateForAllRoles(AccessServiceRoles.Administrator);
     493
    486494      DA.User accessUser;
    487495      DA.aspnet_User aspUser;
     
    529537
    530538    public void DeleteUser(DT.User user) {
     539      roleVerifier.AuthenticateForAllRoles(AccessServiceRoles.Administrator);
     540
    531541      if (user.Id != null && user.Id != Guid.Empty) {
    532542        //delete asp.net user
     
    551561
    552562    public void UpdateUser(DT.User user) {
     563      roleVerifier.AuthenticateForAllRoles(AccessServiceRoles.Administrator);
     564
    553565      AddUser(user);
    554566    }
    555567
    556568    public void AddUserToRole(DT.Role role, DT.User user) {
     569      roleVerifier.AuthenticateForAllRoles(AccessServiceRoles.Administrator);
     570
    557571      //TODO: usernames and rolenames have to be unique!
    558572      MembershipUser msUser = Membership.GetUser((object)user.Id);
     
    563577
    564578    public void RemoveUserFromRole(DT.Role role, DT.User user) {
     579      roleVerifier.AuthenticateForAllRoles(AccessServiceRoles.Administrator);
     580
    565581      MembershipUser msUser = Membership.GetUser((object)user.Id);
    566582      if (msUser != null) {
     
    569585    }
    570586
    571     public bool ResetPassword(Guid userId, string oldPassword, string newPassword) {
     587    public bool ChangePassword(Guid userId, string oldPassword, string newPassword) {
    572588      MembershipUser msUser = Membership.GetUser(userId);
    573589      if (msUser != null) {
     
    575591      }
    576592      return false;
     593    }
     594
     595    public string ResetPassword(Guid userId) {
     596      roleVerifier.AuthenticateForAllRoles(AccessServiceRoles.Administrator);
     597
     598      MembershipUser msUser = Membership.GetUser(userId);
     599      if (msUser != null) {
     600        return msUser.ResetPassword();
     601      } else {
     602        throw new Exception("Password reset failed.");
     603      }
    577604    }
    578605    #endregion
     
    626653
    627654    public void DeleteUserGroup(DT.UserGroup group) {
     655      roleVerifier.AuthenticateForAllRoles(AccessServiceRoles.Administrator);
     656
    628657      using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {
    629658        context.UserGroupBases.DeleteOnSubmit(Convert.ToEntity(group));
     
    733762
    734763    public DT.Role AddRole(DT.Role role) {
     764      roleVerifier.AuthenticateForAllRoles(AccessServiceRoles.Administrator);
     765
    735766      Roles.CreateRole(role.Name);
    736767      return role;
     
    738769
    739770    public void DeleteRole(DT.Role role) {
     771      roleVerifier.AuthenticateForAllRoles(AccessServiceRoles.Administrator);
     772
    740773      Roles.DeleteRole(role.Name);
    741774    }
     
    767800
    768801    public void RemoveRoleFromGroup(DT.UserGroup userGroup, DT.Role role) {
     802      roleVerifier.AuthenticateForAllRoles(AccessServiceRoles.Administrator);
     803
    769804      Guid[] userIds;
    770805      string[] aspUsers;
     
    795830
    796831    public IEnumerable<DT.ClientError> GetClientErrors() {
     832      roleVerifier.AuthenticateForAllRoles(AccessServiceRoles.Administrator);
     833
    797834      using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {
    798835        var query = from c in context.ClientErrors
     
    803840
    804841    public IEnumerable<DT.ClientError> GetLastClientErrors(DateTime startDate) {
     842      roleVerifier.AuthenticateForAllRoles(AccessServiceRoles.Administrator);
     843
    805844      using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {
    806845        var query = from c in context.ClientErrors
     
    812851
    813852    public void DeleteError(DT.ClientError error) {
     853      roleVerifier.AuthenticateForAllRoles(AccessServiceRoles.Administrator);
     854
    814855      using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {
    815856        var query = context.ClientErrors.Where(x => x.Id == error.Id);
  • branches/ClientUserManagement/HeuristicLab.Services.Access/3.3/IAccessService.cs

    r7611 r7612  
    104104
    105105    #region User
    106     //TODO: i don't think this method is needed
    107106    [OperationContract]
    108107    LightweightUser Login();
     
    142141
    143142    [OperationContract]
    144     bool ResetPassword(Guid userId, string oldPassword, string newPassword);
     143    bool ChangePassword(Guid userId, string oldPassword, string newPassword);
     144
     145    [OperationContract]
     146    string ResetPassword(Guid userId);
    145147    #endregion
    146148
Note: See TracChangeset for help on using the changeset viewer.