Exemplo n.º 1
0
        public IActionResult Register(Account account)
        {
            AccountMethods methods  = new AccountMethods();
            string         errormsg = "";

            int accountId = methods.CreateAccount(account, out errormsg);

            if (accountId < 1)
            {
                ViewBag.error = errormsg;
                return(View());
            }
            else
            {
                accountId = methods.getAccount(account, out errormsg);

                var acc  = _context.Account.FindAsync(accountId);
                var name = acc.Result.Mail;


                string session = JsonConvert.SerializeObject(accountId);
                HttpContext.Session.SetString("user", session);
                HttpContext.Session.SetString("username", name);

                return(RedirectToAction("Index", "Compositions"));
            }
        }
        public async Task <BodyResponse <AccountInfo> > Handle(GetAccountBaseInfoCommand request, CancellationToken cancellationToken)
        {
            var accountInfo = await AccountMethods.GetAccountInfo(request.Id, _accountRepository, _redis);

            if (accountInfo == null)
            {
                return(new BodyResponse <AccountInfo>(StatusCodeDefines.AccountError, null));
            }
            return(new BodyResponse <AccountInfo>(StatusCodeDefines.Success, null, accountInfo));
        }
        public async Task <BodyResponse <GetIdByPlatformMqResponse> > Handle(GetIdByPlatformCommand request, CancellationToken cancellationToken)
        {
            long?id = await AccountMethods.GetIdByPlatForm(request.PlatformAccount, _accountRepository, _redis);

            if (id != null)
            {
                return(new BodyResponse <GetIdByPlatformMqResponse>(StatusCodeDefines.Success, null, new GetIdByPlatformMqResponse(id.Value)));
            }

            return(new BodyResponse <GetIdByPlatformMqResponse>(StatusCodeDefines.Error));
        }
        public void TestVerifiyCredentialsNotEmpty()
        {
            var sut = new AccountMethods(CredentialContextFixture.CredentialContext);

            var credentials = sut.VerifyCredentials();

            _output.WriteLine(credentials);

            Assert.False(string.IsNullOrEmpty(credentials));
            Assert.Contains("id", credentials);
            Assert.Contains("username", credentials);
        }
        public void InvalidCredentialsIsReturnedWhenInvalidCredentialIsPassed(string userName, string password)
        {
            ICredentialContext credentialContext = new CredentialContext
            {
                UserName = userName,
                Password = password
            };
            var sut = new AccountMethods(credentialContext);

            string actual = sut.VerifyCredentials();

            _output.WriteLine(actual);

            const string expected = "Invalid credentials";

            Assert.True(expected == actual);
        }
Exemplo n.º 6
0
        private static void TestCredentials(ICredentialContext credential)
        {
            string responseFromServer = new AccountMethods(credential).VerifyCredentials();

            Console.WriteLine(responseFromServer);
        }