Exemple #1
0
        public async Task <User> GetUser(UserLookupOptions options = null)
        {
            if (HttpContext.Items.ContainsKey("CurrentUser"))
            {
                return((User)HttpContext.Items["CurrentUser"]);
            }
            var token = HttpUtilities.TryGetSession(HttpContext);

            return(token == null ? null : await Mediator.Send(new GetUserBySessionOrApiKeyQuery { Session = token, Options = options }));
        }
        public static IMvcBuilder AddThreaxUserLookup(this IMvcBuilder builder, Action <UserLookupOptions> configure)
        {
            builder.Services.AddScoped <AppMapper>(s => new AppMapper());

            var options = new UserLookupOptions();

            configure.Invoke(options);

            builder.Services.TryAddScoped(typeof(IUserSearchService), options.UserSearchServiceType);

            return(builder);
        }
Exemple #3
0
        public async Task <ActionResult <User> > Me([FromBody] UserLookupOptions options, [FromQuery] bool full)
        {
            options ??= new UserLookupOptions();
            options.FullUser       = full || options.IncludeBalance;
            options.IncludeBalance = options.IncludeBalance || options.FullUser;
            var user = await GetUser(options);

            user = options.IncludeBalance
                ? await Mediator.Send(new GetUserByIdQuery
                                      { Id = user.Id, IncludeGroups = options.FullUser, IncludeInstances = options.FullUser })
                : user;

            return(Ok(user));
        }
        public static UserLookupOptions UseIdServer(this UserLookupOptions options)
        {
            options.UserSearchServiceType = typeof(UserSearchService);

            return(options);
        }