public AccountController( AccountService accountService, Auth0Service auth0Service) { this.accountService = accountService; this.auth0Service = auth0Service; }
public AdminService( IRepository <User> userRepository, IAppSettingsProvider appSettings, OwlFinanceDbContext context, Auth0Service auth0, ILogger logger) : base(logger) { this.userRepository = userRepository; this.appSettings = appSettings; this.context = context; this.auth0 = auth0; }
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) { if (!Engine.Services.Installed) { context.Result = new RedirectToRouteResult( new RouteValueDictionary( new { controller = "Install", action = "Install" } ) ); return; } if (Engine.Configuration.InitializeOnStartup || Engine.Auth0Configuration.SetupRemoteOnIntitialize) { if (Engine.Auth0Enabled && Engine.Auth0Configuration.SetupRemoteOnIntitialize) { var authService = new Auth0Service(); await authService.InitialiseApp(); } context.Result = new RedirectToRouteResult( new RouteValueDictionary( new { controller = "Install", action = "Initialized" } ) ); return; } await next(); }
public AppState(Auth0Service auth0Service) { _auth0Service = auth0Service; _auth0Service.LoginSuccess += LoggedIn; }
public virtual async Task <Response> SetRole(string id, string role, bool add) { try { ApplicationUser user = await _account.GetUserByIdAsync(id); ApplicationRole applicationRole = await _account.GetRoleAsync(role); if (!await _account.RoleExistsAsync(role)) { await _account.CreateRoleAsync(role); } var roles = new List <ApplicationRole>() { applicationRole }; var auth0Service = new Auth0Service(); if (add) { await _account.AddUserToRolesAsync(user, roles.ToArray()); if (Engine.Auth0Enabled) { await auth0Service.AddUserToRolesAsync(user, roles.ToArray()); } } else { await _account.RemoveUserFromRolesAsync(user, roles.ToArray()); if (Engine.Auth0Enabled) { await auth0Service.RemoveUserFromRolesAsync(user, roles.ToArray()); } } if (Engine.Auth0Enabled) { // sync remote roles. var primaryAccount = user.GetPrimaryIdentity(); if (primaryAccount != null) { var remoteRoles = await auth0Service.GetRolesByUserAsync(primaryAccount.Id); var remoteRoleNames = remoteRoles.Select(r => r.Name).ToList(); await auth0Service.SyncLocalRoles(user, remoteRoleNames); } } if (add) { return(await SuccessResponseAsync <BaseUsersController>($"The user has been added the {role} role.")); } else { return(await SuccessResponseAsync <BaseUsersController>($"The user has been removed from the {role} role.")); } } catch (Exception ex) { if (add) { return(await ErrorResponseAsync <BaseUsersController>($"Error adding a user to a role via the admin panel.", ex)); } else { return(await ErrorResponseAsync <BaseUsersController>($"Error removing a user from a role via the admin panel.", ex)); } } }
public RegisterUser(Auth0Service auth0Service) { _auth0Service = auth0Service; }