Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4005


Ignore:
Timestamp:
07/06/10 21:31:16 (14 years ago)
Author:
jhaider
Message:

added implementation (#1080)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Services.Authentication Prototype/Service/Provider/HeuristicLabMembershipProvider.cs

    r4004 r4005  
    289289
    290290    public override string GetPassword(string username, string answer) {
    291 
    292       throw new NotImplementedException();
     291      if (PasswordFormat == MembershipPasswordFormat.Hashed)
     292        throw new NotSupportedException("Passwort is hashed");
     293      using (DataClassesDataContext db = DatabaseUtil.createDataClassesDataContext()) {
     294        HeuristicLabUser u =
     295          db.HeuristicLabUsers.Single<HeuristicLabUser>(x => x.UserName == username);
     296        if (EnablePasswordRetrieval && RequiresQuestionAndAnswer) {
     297          if (u.PasswordAnswer.Equals(answer)) {
     298            return u.Password;
     299          } else {
     300            throw new MembershipPasswordException();
     301          }
     302        } else throw new NotSupportedException("PasswortRetrival or RequiresQuestionAndAnswer not set");
     303      }
    293304    }
    294305
    295306    public override MembershipUser GetUser(string username, bool userIsOnline) {
    296       throw new NotImplementedException();
     307      using (DataClassesDataContext db = DatabaseUtil.createDataClassesDataContext()) {
     308        HeuristicLabUser u =
     309            db.HeuristicLabUsers.Single<HeuristicLabUser>(x => x.UserName == username);
     310        if (u != null)
     311          return u.getMembershipUser(this.Name);
     312        else
     313          return null;
     314      }
    297315    }
    298316
    299317    public override MembershipUser GetUser(object providerUserKey, bool userIsOnline) {
    300       throw new NotImplementedException();
     318      long ID = providerUserKey is long ? (long)providerUserKey : -1;
     319      using (DataClassesDataContext db = DatabaseUtil.createDataClassesDataContext()) {
     320        HeuristicLabUser u =
     321            db.HeuristicLabUsers.Single<HeuristicLabUser>(x => x.ID == ID);
     322        if (u != null)
     323          return u.getMembershipUser(this.Name);
     324        else
     325          return null;
     326      }
    301327    }
    302328
    303329    public override string GetUserNameByEmail(string email) {
    304       throw new NotImplementedException();
    305     }
    306 
    307 
     330      using (DataClassesDataContext db = DatabaseUtil.createDataClassesDataContext()) {
     331        HeuristicLabUser u =
     332          db.HeuristicLabUsers.Single<HeuristicLabUser>(x => x.Email == email);
     333        if (u != null)
     334          return u.UserName;
     335        else
     336          return null;
     337      }
     338    }
    308339
    309340    public override string ResetPassword(string username, string answer) {
    310       throw new NotImplementedException();
     341      throw new NotSupportedException("Restet password not avaliable");
    311342    }
    312343
Note: See TracChangeset for help on using the changeset viewer.