Created
July 11, 2016 11:15
-
-
Save ivaneftimov/9accb72f9fe36599002202aa5e1c5b6d to your computer and use it in GitHub Desktop.
Custom membership provider
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SitefinityWebApp\Providers\CustomMembershipProvider.cs | |
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using Telerik.Sitefinity.Model; | |
| using Telerik.Sitefinity.Security.Data; | |
| using Telerik.Sitefinity.Security.Model; | |
| namespace SitefinityWebApp.Providers | |
| { | |
| public class CustomMembershipProvider : MembershipDataProvider | |
| { | |
| public override User GetUser(Guid id) | |
| { | |
| return this.GetUsers().First(u => u.Id == id); | |
| } | |
| public override IQueryable<User> GetUsers() | |
| { | |
| ////////////////// Satatic user data ///////////////////////// | |
| var user1 = new User() | |
| { | |
| Email = "first@user.com", | |
| Id = Guid.Parse("23811D98-7072-47DE-8D08-F30DD8E0C61F"), | |
| FirstName = "Ivan", | |
| LastName = "Eftimov", | |
| ApplicationName = this.ApplicationName | |
| }; | |
| user1.SetUserName("first@user.com"); | |
| ((IDataItem)user1).Provider = this; | |
| var user2 = new User() | |
| { | |
| Email = "second@user.com", | |
| Id = Guid.Parse("5b46c6e0-4655-4b5f-9e05-fdf655d63ec2"), | |
| FirstName = "John", | |
| LastName = "Smith", | |
| ApplicationName = this.ApplicationName | |
| }; | |
| user2.SetUserName("second@user.com"); | |
| ((IDataItem)user2).Provider = this; | |
| /////////////// End of static user data //////////////////////// | |
| return new List<User>() | |
| { | |
| user1, | |
| user2 | |
| } | |
| .AsQueryable(); | |
| } | |
| public override User CreateUser(string userName) | |
| { | |
| throw new NotImplementedException(); | |
| } | |
| public override User CreateUser(Guid id, string userName) | |
| { | |
| throw new NotImplementedException(); | |
| } | |
| public override void Delete(User item) | |
| { | |
| throw new NotImplementedException(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment