Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Taylor Mitchell 19 posts 43 karma points
    Nov 09, 2015 @ 18:02
    Taylor Mitchell
    0

    Create backend users with Additional User Fields

    I'm working on building a new section for Umbraco that uses an external API. The external API needs that user to store their username and password for each individual user. Please do not confuse this with membership. I know you can add additional fields there, but that is not what I'm asking. It's extremely important that I figure this out. Is there a way to possibly just extend the Umbraco user class?

  • Taylor Mitchell 19 posts 43 karma points
    Nov 16, 2015 @ 21:52
    Taylor Mitchell
    1

    Since I didn't get a reply, I will let you know my solution. I built this in order to be able to add usernames and passwords for an API which I am using for a new section in the backend. I ended up building a petapoco model that gets created into the database.

    My model:

    [TableName("MyApiUsers")]
    [PrimaryKey("Id", autoIncrement = true)]
    [ExplicitColumns]
    public class MyApiUser
    {
        [Column("Id")]
        [PrimaryKeyColumn(AutoIncrement = true)]
        public int Id { get; set; }
    
        //umbraco user id
        [Column("UserId")]
        public string UserId { get; set; }
    
        [Column("UserName")]
        public string UserName { get; set; }
    
        //to be hashed later
        [Column("Password")]
        public string Password { get; set; }
    }
    

    Global.asax

    public class MvcApplication : ApplicationEventHandler
    {
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            var db = applicationContext.DatabaseContext.Database;
    
            if (!db.TableExist("MyApiUsers"))
            {
                db.CreateTable<MyApiUser>(false);
            }
        }
    }
    

    This allowed me to link my users to an api username and password. Hope this helps anyone looking.

  • Krishna 22 posts 52 karma points
    Nov 25, 2015 @ 01:15
    Krishna
    0

    Thanks very helpful. Need something like this. I am developing a custom section and need to enforce authorization rules to different features within the custom section application. I further need the Umbraco administrator have the ability to manage these authorization rules. Much like the being able to control the permissions from the "User Permissions".

    Any thoughts?

    Thanks, Krishna

Please Sign in or register to post replies

Write your reply to:

Draft