public async Task <IActionResult> Register(RegisterViewModel _model, string _returnUrl = null) { ViewData["ReturnUrl"] = _returnUrl; if (ModelState.IsValid) { var _user = new IdentityDBContext { UserName = _model.Email, Email = _model.Email }; var _result = await _userManager.CreateAsync(_user, _model.Password); if (_result.Succeeded) { _logger.LogInformation("User created a new account with password."); var _code = await _userManager.GenerateEmailConfirmationTokenAsync(_user); //var _callbackUrl = Url.EmailConfirmationLink(_user.Id, _code, Request.Scheme); //await _emailSender.SendEmailAsync(_model.Email, _callbackUrl); await _signInManager.SignInAsync(_user, isPersistent : false); _logger.LogInformation("User created a new account with password."); return(RedirectToLocal(_returnUrl)); } AddErrors(_result); } return(View(_model)); }
public static void AssignMenuToModel(Menu menu) { IdentityDBContext db = new IdentityDBContext(); RoleManager <AppRole> RoleManager = new RoleManager <AppRole>(new RoleStore <AppRole>(db)); var activeRoles = RoleManager.Roles.Where(rol => rol.activo); var menusCreados = activeRoles.Select(rol => new MenuByArea() { id_area = rol.Id, Nombre = rol.Name }).ToList(); if (menu.id != 0) { menusCreados = activeRoles.Select(rol => new MenuByArea() { id_area = rol.Id, Nombre = rol.Name, id_menu = menu.id }).ToList(); menusCreados.ForEach(menuAreaCreado => { menuAreaCreado.Asignado = menu.MenuByAreas.Any(menuArea => menuArea.id_area == menuAreaCreado.id_area); }); } menu.MenuByAreas = menusCreados; }
public void ConfigureRoles() { using (IdentityDBContext context = new IdentityDBContext()) { var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(context)); var UserManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context)); // Admin role if (!roleManager.RoleExists("Manager")) { // Create admin role roleManager.Create(new IdentityRole("Manager")); // Create admin account var user = new ApplicationUser { UserName = "******", Email = "*****@*****.**", }; string password = "******"; var createUserTransaction = UserManager.Create(user, password); if (createUserTransaction.Succeeded) { UserManager.AddToRole(user.Id, "Manager"); } } // Mortals role if (!roleManager.RoleExists("Employee")) { roleManager.Create(new IdentityRole("Employee")); } } }
public static IEnumerable <ApiResource> GetApiResource(String Connectionstring) { IdentityDBContext _db = new IdentityDBContext(new DbContextOptionsBuilder <IdentityDBContext>().UseSqlServer(Connectionstring).Options); List <ApiResource> apiresources = new List <ApiResource>(); foreach (IdentityServer.Models.Application app in _db.Applications.ToList()) { apiresources.Add(new ApiResource(app.Name, app.Name)); } return(apiresources); }
// GET: Account public AccountController() { IdentityDBContext DB = new IdentityDBContext(); UserStore <ApplicationUser> userStore = new UserStore <ApplicationUser>(DB); userManager = new UserManager <ApplicationUser>(userStore); //manager'ı hangi store üzerinde barındırmak istiyorsun diye soruyor veriyorum barındırmak istediğim yeri RoleStore <ApplicationRole> roleStore = new RoleStore <ApplicationRole>(DB); //Gene bu manager'ı hangi store üzerinde barındırmak istediğimi soruyor. roleManager = new RoleManager <ApplicationRole>(roleStore); //rolStore'dan türettim }
public async Task <IEnumerable <UserOwnership> > GetUserOwnershipAsync(string UserID) { using (var _context = new IdentityDBContext(_dbOptions)) { var task = await _context.UserOwnership.Where(u => u.UserId.Equals(UserID, StringComparison.InvariantCultureIgnoreCase)).AsNoTracking().ToListAsync(); if (task == null || !task.Any()) { return(null); } return(task); } }
public async Task <UserOwnership> GetUserOwnershipAsync(UserOwnership userOwnership) { using (var _context = new IdentityDBContext(_dbOptions)) { var task = await _context.UserOwnership.FindAsync(userOwnership.UserId, userOwnership.ConferenceId); if (task == null) { return(null); } return(task); } }
public async Task <UserAgenda> GetUserAgendaAsync(UserAgenda userAgenda) { using (var _context = new IdentityDBContext(_dbOptions)) { var task = await _context.UserAgenda.FindAsync(userAgenda.UserId, userAgenda.ConferenceId, userAgenda.SessionId, userAgenda.TalkId); if (task == null) { return(null); } return(task); } }
public async Task <UserOwnership> AddUserOwnershipAsync(UserOwnership userOwnership) { using (var _context = new IdentityDBContext(_dbOptions)) { var exists = GetUserOwnershipAsync(userOwnership).Result; if (exists != null) { return(exists); } _context.UserOwnership.Add(userOwnership); await _context.SaveChangesAsync(); return(GetUserOwnershipAsync(userOwnership).Result); } }
public async Task <UserAgenda> DeleteUserAgenda(string userId, int conferenceId, int sessionId, int talkId) { using (var _context = new IdentityDBContext(_dbOptions)) { var task = await _context.UserAgenda.FindAsync(userId, conferenceId, sessionId, talkId); if (task == null) { return(null); } _context.UserAgenda.Remove(task); await _context.SaveChangesAsync(); return(task); } }
public async Task <UserOwnership> DeleteUserOwnership(string userId, int conferenceId) { using (var _context = new IdentityDBContext(_dbOptions)) { var task = await _context.UserOwnership.FindAsync(userId, conferenceId); if (task == null) { return(null); } _context.UserOwnership.Remove(task); await _context.SaveChangesAsync(); return(task); } }
//Global.asax applicationsal işlemlerimi yapar. protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); IdentityDBContext DB = new IdentityDBContext(); RoleStore <ApplicationRole> rStore = new RoleStore <ApplicationRole>(DB); RoleManager <ApplicationRole> rManager = new RoleManager <ApplicationRole>(rStore); if (!rManager.RoleExists("Admin")) { ApplicationRole adminRole = new ApplicationRole("Admin", "SistemYöneticisi"); rManager.Create(adminRole); } if (!rManager.RoleExists("User")) { ApplicationRole userRole = new ApplicationRole("User", "SistemKullanici"); rManager.Create(userRole); } }
public static IEnumerable <IdentityServer4.Models.Client> GetClients(String Connectionstring) { IdentityDBContext _db = new IdentityDBContext(new DbContextOptionsBuilder <IdentityDBContext>().UseLazyLoadingProxies().UseSqlServer(Connectionstring).Options); List <IdentityServer4.Models.Client> clientes = new List <IdentityServer4.Models.Client>(); foreach (IdentityServer.Models.Client cli in _db.Clients.ToList()) { IdentityServer4.Models.Client icli = new IdentityServer4.Models.Client(); icli.ClientId = cli.UserName; icli.AllowedGrantTypes = GrantTypes.ClientCredentials; icli.ClientSecrets.Add(new Secret(cli.Password.Sha256())); foreach (Scope scope in _db.Scopes.ToList()) { if (scope.ClientId == cli.ClientId) { icli.AllowedScopes.Add(scope.ApplicationId.ToString()); } } clientes.Add(icli); } return(clientes); }
public ScopesController(IdentityDBContext context) { _context = context; }
public DataAdapter(IdentityDBContext identityDbContext) { this.identityDbContext = identityDbContext; }
public ToDoController(IdentityDBContext identityDBContext) { _identityDBContext = identityDBContext; }
public HomeController(IdentityDBContext identityDBContext) { _identityDBContext = identityDBContext; }
public ApplicationUserStore(IdentityDBContext context) : base(context) { }
public IdentityController(IdentityDBContext dbcontext, IConfiguration config) { db = dbcontext; configuration = config; }
public RegisterUserCommandHandler(IdentityDBContext dbContext) { _dbContext = dbContext; }
public EmailSender(IdentityDBContext idContext, IOptions <EmailConfig> emailConfig) { _idContext = idContext; _emailConfig = emailConfig?.Value; }
protected BaseService(IContextProvider contextProvider, ILoggerFactory loggerFactory, IdentityDBContext context) : base(loggerFactory) { _session = contextProvider.GetCurrentContext(); _context = context; }
public HomeController(IdentityDBContext dbContext) { _dbContext = dbContext; }
public RegisterUserCommandHandler(IdentityDBContext dbContext, IKafkaMessageBus <string, User> bus) { _bus = bus; _dbContext = dbContext; }
public CustomerUpdatedEventHandler(IdentityDBContext dbContext) { _dbContext = dbContext; }
public IdentityRepository(IdentityDBContext context, IMapper mapper) : base(context, mapper) { this.context = context; this.mapper = mapper; }
public SettingsService(IContextProvider contextProvider, ILoggerFactory loggerFactory, IdentityDBContext context) : base(contextProvider, loggerFactory, context) { }
public AuthService(IdentityDBContext context, IConfiguration configuration) { _configuration = configuration; _context = context; }
public ApplicationsController(IdentityDBContext context) { _context = context; }
public IdentityController(IdentityDBContext dbContext, IConfiguration configuration) { db = dbContext; config = configuration; }