/// <inheritdoc/>
    public Task <Maybe <AuthUserRoleId> > CreateAsync(AuthUserId userId, AuthRoleId roleId)
    {
        var userRole = new AuthUserRoleEntity
        {
            UserId = userId,
            RoleId = roleId
        };

        return(CreateAsync(userRole));
    }
Example #2
0
 public async Task <IActionResult> ShowUser(AuthUserId id) =>
 await Auth
 .User.RetrieveAsync <UpdateUserModel>(
     id
     )
 .MapAsync(
     x => View(x),
     F.DefaultHandler
     )
 .UnwrapAsync(
     x => x.Value(() => View("Unknown"))
     )
 .ConfigureAwait(false);
Example #3
0
 /// <inheritdoc/>
 public Task <Maybe <List <TRole> > > GetRolesForUserAsync <TRole>(AuthUserId userId)
     where TRole : IAuthRole =>
 F.Some(userId)
 .BindAsync(
     x => this.QueryAsync <TRole>(builder => builder
                                  .From <AuthRoleTable>()
                                  .Join <AuthRoleTable, AuthUserRoleTable>(QueryJoin.Inner, r => r.Id, ur => ur.RoleId)
                                  .Where <AuthUserRoleTable>(ur => ur.UserId, Compare.Equal, x.Value)
                                  )
     )
 .MapAsync(
     x => x.ToList(),
     F.DefaultHandler
     );
Example #4
0
 /// <summary>
 /// Update the last sign in for a user
 /// </summary>
 /// <param name="auth"></param>
 /// <param name="user"></param>
 /// <param name="log"></param>
 public static Task <Maybe <bool> > UpdateUserLastSignInAsync(IAuthDataProvider auth, AuthUserId user, ILog log)
 {
     log.Vrb("Updating last sign in for user {UserId}.", user.Value);
     return(auth.User.UpdateLastSignInAsync(user)
            .AuditAsync(none: log.Msg)
            .SwitchAsync(
                some: x => F.Some(x),
                none: false
                ));
 }