Example #1
0
 public AccountController(IOwinContext context, IQuartzTaskService quartzTaskService, ILogger logger)
 {
     this._userService           = context.GetUserManager <UserService>();
     this._roleService           = context.Get <RoleService>();
     this._signInService         = context.Get <SignInService>();
     this._authenticationService = context.Authentication;
 }
Example #2
0
        public AccountController(SignInService signInService,
                                 UserService userService)
        {
            _userService = userService;

            _signInService = signInService;
        }
        public async Task <IDataResult <TokenModel> > SignInAsync(SignInModel signInModel)
        {
            var validation = new SignInModelValidator().Valid(signInModel);

            if (!validation.Success)
            {
                return(new ErrorDataResult <TokenModel>(validation.Message));
            }

            var signedInModel = await UserRepository.SignInAsync(signInModel);

            if (!SignInService.Validate(signedInModel, signInModel))
            {
                return(new ErrorDataResult <TokenModel>(Texts.LoginPasswordInvalid));
            }

            var tokenModel = SignInService.CreateToken(signedInModel);

            var addUserLogModel = new AddUserLogModel(signedInModel.UserId, LogType.SignIn);

            await UserLogApplicationService.AddAsync(addUserLogModel);

            await UnitOfWork.SaveChangesAsync();

            return(new SuccessDataResult <TokenModel>(tokenModel));
        }
        public void RegisterUser_ShortUsername_False()
        {
            var options = new DbContextOptionsBuilder <Mystivate_dbContext>()
                          .UseInMemoryDatabase(databaseName: "RegisterUser_ShortUsername_False")
                          .Options;

            using (var context = new Mystivate_dbContext(options))
            {
                IAccountAccess accountAccess = new AccountAccess(context);

                IRegisterService registerService = new SignInService(null, accountAccess);

                string username = "******";
                string email    = "*****@*****.**";
                string password = "******";

                RegisterResult result = registerService.RegisterUser(new RegisterModel
                {
                    Email    = email,
                    Username = username,
                    Password = password
                });

                Assert.AreEqual(RegisterResult.UsernameShort, result);
            }
        }
Example #5
0
        /// <summary>
        /// This sample illustartes a simplified token exhange flow.
        /// The configurations neccessary in HelseID are:
        ///
        /// The subject-client which is an ordinary client
        /// The client is configured with:
        ///     - grant_type: authorization_code
        ///     - secret: some enterprise sertificate
        ///     - scopes: an api-scope which belongs to the api doing token exchange
        ///
        /// The api-resource being called by the subject-client.
        /// The resource is configured with:
        ///     - scopes: the api scope used by the subject client.
        ///     - user claims: pid, security_level
        ///
        ///
        /// The actor-client. This is the client doing token exchange on behalf of the api-resource.
        /// The client is configured with:
        ///     - grant_type: token_exchange
        ///     - secret: some enterprise certificate
        ///     - scopes: the scopes of other API-s the api-resource needs access to
        ///
        ///
        /// NOTE: For convenience we are using the same enterprise certificate for the subject and actor client.
        ///       In normal use cases this would be two different certificates.
        ///
        /// </summary>
        /// <returns></returns>
        public static async Task MainAsync()
        {
            var settings             = GetSettings();
            var signinService        = new SignInService(settings);
            var tokenExchangeService = new TokenExchangeService(settings);

            Console.WriteLine("+---------------------------------------+");
            Console.WriteLine("|      Token Exchange Demo Client       |");
            Console.WriteLine("+---------------------------------------+");
            Console.WriteLine("");

            Console.WriteLine("Logging in and retrieving subject access token...");


            // Authenticate user, using an enterprise certifikate as client secret
            var subjectToken = await signinService.SignIn();

            Console.WriteLine("Exchanging token...");

            // In a real-world scenarion we would pass the subject token (which
            // is an access token) on to an API, and that API would do the Token Exchange.
            // Here we do the exchange on the fly.
            var teToken = await tokenExchangeService.Exchange(subjectToken);

            Console.WriteLine("Token exchange complete.");
            PrintTokens(subjectToken, teToken);

            Console.WriteLine("Press any key...");
            Console.ReadKey();
        }
Example #6
0
 /// <summary>
 ///     Create new instance.
 /// </summary>
 public UserController(IMapper mapper, Core.AppContext appContext, IUserRepository userRepository, SignInService signInService)
 {
     _mapper         = mapper ?? throw new ArgumentNullException(nameof(mapper));
     _appContext     = appContext ?? throw new ArgumentNullException(nameof(appContext));
     _userRepository = userRepository ?? throw new ArgumentNullException(nameof(userRepository));
     _signInService  = signInService ?? throw new ArgumentNullException(nameof(signInService));
 }
        public async Task <IDataResult <TokenModel> > SignInAsync(SignInModel signInModel)
        {
            var validation = new SignInModelValidator().Validate(signInModel);

            if (validation.IsError)
            {
                return(DataResult <TokenModel> .Error(validation.Message));
            }

            var signedInModel = await UserRepository.SignInAsync(signInModel);

            validation = SignInService.Validate(signedInModel, signInModel);

            if (validation.IsError)
            {
                return(DataResult <TokenModel> .Error(validation.Message));
            }

            var userLogModel = new UserLogModel(signedInModel.Id, LogType.SignIn);

            await UserLogApplicationService.AddAsync(userLogModel);

            await UnitOfWork.SaveChangesAsync();

            var tokenModel = SignInService.CreateToken(signedInModel);

            return(DataResult <TokenModel> .Success(tokenModel));
        }
Example #8
0
 public AccountController(UserService userService, SignInService signInService, MediaService mediaService, MessageService messageService, AppService appService)
 {
     _userService    = userService;
     _signInService  = signInService;
     _mediaService   = mediaService;
     _messageService = messageService;
     _appService     = appService;
 }
Example #9
0
        public ActionResult LogOut()
        {
            var _singIn = new SignInService();

            _singIn.IdentitySignout();
            OcelotLog.AuditLogs($"{Constant.GetUserID()} at {DateTime.Now} signed out.", "AccountCOntroller", "Login");
            return(RedirectToAction("Index"));
        }
        public NameEntryViewModel(INavigationService navigationService, SignInService signInService, ToastService toastService)
        {
            this.navigationService = navigationService;
            this.signInService     = signInService;
            this.toastService      = toastService;

            this.SubmitCommand = new DelegateCommand(this.Submit, this.CanSubmit);
        }
 public SignOutViewModel(
     INavigationService navigationService,
     SignInService signInService,
     ToastService toastService)
 {
     this.navigationService = navigationService;
     this.signInService     = signInService;
     this.toastService      = toastService;
 }
Example #12
0
        public OffsiteStorageService(SignInService signInService, MessagingClient messagingClient)
        {
            this.signInService   = signInService;
            this.messagingClient = messagingClient;
            this.messagingClient.PersonSignedIn  += (s, e) => this.Update();
            this.messagingClient.PersonSignedOut += (s, e) => this.Update();

            this.fileId = Environment.GetEnvironmentVariable("GoogleDriveFileId");
        }
Example #13
0
        public void ThrowArgumentNullException_WhenSingInServiceIsNull()
        {
            // Arrange
            SignInService signInService   = null;
            var           userServiceMock = new Mock <IUserService>();

            // Act & Assert
            Assert.Throws <ArgumentNullException>(() => new AccountController(signInService, userServiceMock.Object));
        }
Example #14
0
        public SignInService GetSignInService()
        {
            if (signInService == null)
            {
                signInService = new SignInService(GetProfileRepository(), GetUsersRepository());
            }

            return(signInService);
        }
Example #15
0
 public AccountController(IAdministratorRepository administratorRepository, AuthenticationService authenticationService, SignInService signInService, AdvertiserAccountService advertiserAccountService, IAdvertiserRepository advertiserRepository, AdministratorAccountService administratorAccountService)
 {
     _administratorRepository     = administratorRepository;
     _authenticationService       = authenticationService;
     _signInService               = signInService;
     _advertiserAccountService    = advertiserAccountService;
     _advertiserRepository        = advertiserRepository;
     _administratorAccountService = administratorAccountService;
 }
Example #16
0
 public SigninController(IWeixinRespository weixinRespository,
                         ISigInRecordRespository sigInRecordRespository,
                         SignInService signInService,
                         IActivityRespository activityRespository)
 {
     _weixinRespository      = weixinRespository;
     _sigInRecordRespository = sigInRecordRespository;
     _signInService          = signInService;
     _activityRespository    = activityRespository;
 }
Example #17
0
 public AuthService(AuthenticationStateProvider authenticationStateProvider,
                    ServerHandler serverHandler,
                    SignUpService signUpService,
                    SignInService signInService)
 {
     this.authenticationStateProvider = authenticationStateProvider;
     this.serverHandler = serverHandler;
     this.signUpService = signUpService;
     this.signInService = signInService;
 }
Example #18
0
 /// <summary>
 ///     Create new instance.
 /// </summary>
 public OrganizationUserAdminController(
     IMapper mapper,
     IUserRepository userRepository,
     IOrganizationUserRepository organizationUserRepository,
     SignInService signInService)
 {
     _mapper                     = mapper ?? throw new ArgumentNullException(nameof(mapper));
     _userRepository             = userRepository ?? throw new ArgumentNullException(nameof(userRepository));
     _organizationUserRepository = organizationUserRepository ?? throw new ArgumentNullException(nameof(organizationUserRepository));
     _signInService              = signInService ?? throw new ArgumentNullException(nameof(signInService));
 }
Example #19
0
        public void CanChangePassword()
        {
            SignInService service = CreateSignInService();

            string newPassword = "******";

            service.ChangePassword(1, "owner", "pass1234", newPassword);
            User u = service.Login(1, "owner", newPassword);

            Assert.IsNotNull(u);
        }
        public SignInEventProcessor(
            MessagingClient messagingClient,
            SignInService signInService,
            TokenHolderService tokenHolderService)
        {
            this.messagingClient    = messagingClient;
            this.signInService      = signInService;
            this.tokenHolderService = tokenHolderService;

            this.messagingClient.SignInRequestSubmitted  += (s, e) => this.eventProcessingQueue.Add(async() => await this.ProcessSignIn(e));
            this.messagingClient.SignOutRequestSubmitted += (s, e) => this.eventProcessingQueue.Add(async() => await this.ProcessSignOut(e));
        }
Example #21
0
 public AccountController(IServiceProvider services)
 {
     _userService        = services.GetRequiredService <UserService>();
     _appSettings        = services.GetRequiredService <IOptions <AppSettings> >().Value;
     _appService         = services.GetRequiredService <AppService>();
     _mediaService       = services.GetRequiredService <MediaService>();
     _orderService       = services.GetRequiredService <OrderService>();
     _signInService      = services.GetRequiredService <SignInService>();
     _messageService     = services.GetRequiredService <MessageService>();
     _transactionService = services.GetRequiredService <TransactionService>();
     _paymentProcessor   = services.GetRequiredService <IPaymentProcessor>();
 }
Example #22
0
 public AccountController(
     IOwinContext context,
     ISettingService settingService,
     IAttachmentService attachmentService)
 {
     this._userService           = context.GetUserManager <UserService>();
     this._roleService           = context.Get <RoleService>();
     this._signInService         = context.Get <SignInService>();
     this._settingService        = settingService;
     this._attachmentService     = attachmentService;
     this._authenticationService = context.Authentication;
 }
Example #23
0
        public UsuariosController(UserService userService,
                                  SignInService signInService,
                                  RoleService roleService,
                                  IUsuariosManager usuariosManager)
        {
            _userService = userService;

            _signInService = signInService;

            _roleService = roleService;

            _usuarioManager = usuariosManager;
        }
Example #24
0
 protected void Session_Start(object sender, EventArgs e)
 {
     Session["init"] = 0;
     if (HttpContext.Current.User.Identity.IsAuthenticated)
     {
         SignInService svcSignIn = new SignInService(AppService.Current.Data.Context);
         int           UserId    = svcSignIn.GetUserId(HttpContext.Current.User.Identity.Name);
         svcSignIn.Save(new SignInEx()
         {
             UserId = UserId, SignInDate = DateTime.Now, SignInType = "Remember"
         });
     }
 }
Example #25
0
        public override void Delete()
        {
            var  learningCircleService = new LearningCircleService();
            var  leanringCircleInfo    = learningCircleService.GetDetailByOuterKey(_parameters.CircleKey.ToLower());
            var  authService           = new AuthService();
            bool _isAdmin = authService.CheckFunctionAuth(leanringCircleInfo.Id, Service.Utility.ParaCondition.SignInFunction.Admin, _parameters.MemberId);

            var _service = new SignInService();

            if (_isAdmin)
            {
                _service.Delete(_parameters.EventId, _parameters.MemberId);
            }
        }
        public void SignOut_SignedUser_EraseToken()
        {
            var init = new InitializeMockContext();
            var mock = init.mock;

            var signInService = new SignInService(mock.Object);
            var result        = signInService.SignOut(new SignOutCommand()
            {
                UserId = 3
            });

            Assert.AreEqual(result, true);
            mock.Verify(m => m.SaveChanges(), Times.Once());
        }
        public void SignIn_ValidEmail_GenerateToken()
        {
            var init = new InitializeMockContext();
            var mock = init.mock;

            var signInService = new SignInService(mock.Object);
            var result        = signInService.SignIn(new SignInCommand()
            {
                Email = "*****@*****.**", Password = "******"
            });

            Assert.AreNotEqual(result.Token, null);
            mock.Verify(m => m.SaveChanges(), Times.Once());
        }
Example #28
0
        public void CanGenerateValidPasswordToken()
        {
            SignInService service = CreateSignInService();
            string        token   = service.SendResetPasswordEmail(1, "owner");

            Assert.IsNotNull(token);

            string newPassword = service.ResetPassword(token);

            Assert.IsNotNull(newPassword);

            User u = service.Login(1, "owner", newPassword);

            Assert.IsNotNull(u);
        }
        public async Task <UserInfoDM> UpdateUserInfo()
        {
            var token = await SignInService.GetToken();

            if (token == null)
            {
                throw new ArgumentNullException("can't get userInfo without token");
            }

            var userInfo = await UserInfoRepository.GetUserInfo(token.AccessToken);

            UserInfoSettingsService.PutUserInfo(userInfo);

            return(userInfo);
        }
    void Awake()
    {
        Debug.Log("---------------  Awake ------------------------");

        foreach (UIFacade facade in uIFacades)
        {
            facade.Register();
        }

        initialize();

        //windowtools
        WindowToolsView viewWindowTools = new WindowToolsView();

        framework.viewCenter.Register(WindowToolsView.NAME, viewWindowTools);

        // quit dialog
        QuitDialogView viewQuitDialog = new QuitDialogView();

        framework.viewCenter.Register(QuitDialogView.NAME, viewQuitDialog);

        // account
        AccountService    serviceAccount    = new AccountService();
        AccountModel      modelAccount      = new AccountModel();
        AccountController controllerAccount = new AccountController();

        framework.modelCenter.Register(AccountModel.NAME, modelAccount);
        framework.controllerCenter.Register(AccountController.NAME, controllerAccount);
        framework.serviceCenter.Register(AccountService.NAME, serviceAccount);

        //signin
        SignInView       viewSignIn       = new SignInView();
        SignInModel      modelSignIn      = new SignInModel();
        SignInController controllerSignIn = new SignInController();
        SignInService    serviceSignIn    = new SignInService();


        serviceSignIn.domain = Constant.Domain;

        /*
         * serviceSignIn.MockProcessor = AuthMock.Processor;
         * serviceSignIn.useMock = true;
         */
        framework.viewCenter.Register(SignInView.NAME, viewSignIn);
        framework.modelCenter.Register(SignInModel.NAME, modelSignIn);
        framework.controllerCenter.Register(SignInController.NAME, controllerSignIn);
        framework.serviceCenter.Register(SignInService.NAME, serviceSignIn);
    }
 public ManageController(UserService userService, SignInService signInService, IAuthenticationManager authManager)
 {
     _userService = userService;
     _signInService = signInService;
     _authManager = authManager;
 }