Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="disposing"></param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && _userManager != null)
            {
                _userManager.Dispose();
                _userManager = null;
            }

            base.Dispose(disposing);
        }
Ejemplo n.º 2
0
        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });


            using (var _repo = new IdentifyConfig.ApplicationUserManager(new UserStore <ApplicationUser>(new ApplicationDbContext())))
            {
                ApplicationUser user = null;
                //Überprüfen ob Mail
                if (context.UserName.Contains("@"))
                {
                    //Suche ob Mail vorhanden
                    var tempUser = await _repo.FindByEmailAsync(context.UserName);

                    if (tempUser != null)
                    {
                        //wenn was gefunden wurde, Überprüfen ob PW stimmt
                        user = await _repo.FindAsync(tempUser.UserName, context.Password);
                    }
                }
                //Übergebener string ist evtl Loginname
                else
                {
                    //Überprüfen ob vorhanden und PW stimmt
                    user = await _repo.FindAsync(context.UserName, context.Password);
                }

                if (user == null)
                {
                    context.SetError("invalid_grant", "The user name or password is incorrect.");
                    return;
                }
            }

            var identity = new ClaimsIdentity(context.Options.AuthenticationType);

            identity.AddClaim(new Claim("sub", context.UserName));
            identity.AddClaim(new Claim("role", "user"));

            context.Validated(identity);
        }
Ejemplo n.º 3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="userManager"></param>
 /// <param name="signInManager"></param>
 public ManageController(IdentifyConfig.ApplicationUserManager userManager, IdentifyConfig.ApplicationSignInManager signInManager)
 {
     UserManager   = userManager;
     SignInManager = signInManager;
 }
Ejemplo n.º 4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="userManager"></param>
 public OfficeHourInfoService(IdentifyConfig.ApplicationUserManager userManager)
 {
     UserManager = userManager;
 }
Ejemplo n.º 5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="userManager"></param>
 public OccurrenceService(IdentifyConfig.ApplicationUserManager userManager)
 {
     UserManager = userManager;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="db"></param>
 /// <param name="userManager"></param>
 public MemberService(TimeTableDbContext db, IdentifyConfig.ApplicationUserManager userManager)
 {
     UserManager = userManager;
     this.db = db;
 }