Beispiel #1
0
 public AccountController(UserManager <KmUser> userManager,
                          SignInManager <KmUser> signinManager,
                          UserTokenService tokenService,
                          AccountConfirmationService accountConfirmationService)
 {
     this.userManager   = userManager;
     this.signinManager = signinManager;
     this.tokenService  = tokenService;
     this.accountConfirmationService = accountConfirmationService;
 }
Beispiel #2
0
        public void When_access_token_is_requested_loads_access_token_from_store()
        {
            // Arrange
            SetupDependencies();
            UserTokenService target = BuildTarget();

            //Act
            var result = target.GetToken(UserIdentifier);

            //Assert
            result.Should().NotBeNull();
            userTokenStore.Verify(s => s.GetToken(UserIdentifier), Times.Once);
        }
Beispiel #3
0
        public async Task When_access_token_generation_is_requested_for_user_gets_and_saves_access_token()
        {
            // Arrange
            SetupDependencies();
            UserTokenService target = BuildTarget();

            //Act
            var result = await target.GenerateTokenAsync(UserIdentifier, "dummycode");

            // Assert
            result.Should().NotBeNull();
            bankAuthTokenProvider.Verify(p => p.GetAccessTokenAsync("dummycode"), Times.Once);
            userTokenStore.Verify(s => s.UpdateToken(UserIdentifier, result), Times.Once);
        }
        /// <summary>
        /// Token alacak kullanıcının, daha önceden aldığı bir token var ise geri döndürür.
        /// </summary>
        /// <param name="userId">Kullanıcı id numarası.</param>
        /// <param name="appId">Uygulama id numarası.</param>
        /// <param name="companyId">Şirket id numarası.</param>
        /// <returns>Geriye UserToken modeli döner.</returns>
        private UserToken GetActiveTokenForUser(int userId, int appId, int companyId)
        {
            UserToken result = null;

            UserTokenService userTokenService = new UserTokenService(connectionHelper);
            var serviceResult = userTokenService.FindToken(userId, appId, companyId);


            if (serviceResult.Result)
            {
                result = serviceResult.Objects.FirstOrDefault();
            }


            return(result);
        }
 public SynthChannelController(
     ILogger <SynthChannelController> logger,
     UserManager <SynthbotUser> userMgr,
     UserService userService,
     PlaybackSessionService playbackSessionService,
     UserTokenService tokenService,
     PlaybackSessionService sessionService,
     PlaybackSessionRepository playbackRepo)
 {
     _logger                 = logger;
     _userManager            = userMgr;
     _userService            = userService;
     _playbackSessionService = playbackSessionService;
     _tokenService           = tokenService;
     _playbackRepo           = playbackRepo;
 }
Beispiel #6
0
 public SongFinishedJob(
     ILogger <SongFinishedJob> logger,
     PlaybackSessionRepository sessionRepo,
     SongPlaybackRepository songRepo,
     SpotifyHttpClientFactory spotifyApiFactory,
     UserTokenService tokenService,
     SpotifyPlaybackService playbackService,
     IScheduler jobScheduler,
     IHubContext <DiscordBotHub> botHub)
 {
     _logger            = logger;
     _sessionRepo       = sessionRepo;
     _songRepo          = songRepo;
     _spotifyApiFactory = spotifyApiFactory;
     _playbackService   = playbackService;
     _jobScheduler      = jobScheduler;
     _botHub            = botHub;
 }
Beispiel #7
0
        public ApiResponse <UserModel> GetUserDetail(int id)
        {
            if (id < 1)
            {
                throw new Exception("Invalid id.");
            }

            var user    = this.UserService.GetUserDetail(id);
            var current = UserTokenService.GetMemberByToken(this.Token);

            UserExtentions.HidePhone(current, user); //隐藏电话号码

            ApiResponse <UserModel> response = new ApiResponse <UserModel>()
            {
                Result = user
            };

            return(response);
        }
Beispiel #8
0
        public ApiResponse <UserModel> GetUserDetail(SingleUserModel model)
        {
            if (model == null || (string.IsNullOrEmpty(model.Phone) && string.IsNullOrEmpty(model.Email) && string.IsNullOrEmpty(model.ChineseName) &&
                                  string.IsNullOrEmpty(model.EnglishName) && string.IsNullOrEmpty(model.QQID)))
            {
                throw new Exception("The request body cant't be null.");
            }

            var user    = this.UserService.GetUserDetail(model);
            var current = UserTokenService.GetMemberByToken(this.Token);

            UserExtentions.HidePhone(current, user); //隐藏电话号码

            ApiResponse <UserModel> response = new ApiResponse <UserModel>()
            {
                Result = user
            };

            return(response);
        }
        public void UserTokenServiceCanExtractUserId()
        {
            var context          = DbContext.Get();
            var userService      = new UserService(context);
            var userTokenService = new UserTokenService(
                userService: userService,
                options: Options.Create(new UserTokenServiceOptions()));

            ClaimsPrincipal principal = new ClaimsPrincipal(new ClaimsIdentity(new Claim[]
            {
                new Claim(ClaimTypes.NameIdentifier, "1")
            }));

            var id = userTokenService.GetUserId(principal);

            Assert.Equal(1, id);

            principal = new ClaimsPrincipal(new ClaimsIdentity(new Claim[0]));
            id        = userTokenService.GetUserId(principal);
            Assert.Null(id);
        }
Beispiel #10
0
 public TestController(ILogger <TestController> logger, UserTokenService userTokenService)
 {
     _logger           = logger;
     _userTokenService = userTokenService;
 }
 public TodoController(TodoService todoService, UserTokenService userTokenService)
 {
     _todoService      = todoService;
     _userTokenService = userTokenService;
 }
Beispiel #12
0
 public AuthorizationController(UserService userService, UserTokenService userTokenService)
 {
     _userService      = userService;
     _userTokenService = userTokenService;
 }
 public UserController(UserService userService, UserTokenService tokenService)
 {
     _userService      = userService;
     _userTokenService = tokenService;
 }
 public UserTokenServiceManager(ConnectionHelper connectionHelper)
 {
     tokenService = new UserTokenService(connectionHelper);
 }