예제 #1
0
        public async Task <JsonResult> ListCredentials(string username, string password, string realmName)
        {
            var userId = await authentication.AuthenticateUser(username, password);

            var bots = await context.Bots
                       .Where(b => b.RealmName == realmName)
                       .Where(b => b.UserId == userId)
                       .OrderBy(b => b.Name)
                       .ToListAsync();

            return(Json(bots.Select(b => new BotDetailViewModel(b))));
        }
        public async Task <JsonResult> Show(
            string username,
            string password,
            string characterName,
            string realmName)
        {
            var userID = await authentication.AuthenticateUser(username, password);

            var bot = await context.Bots.FirstOrDefaultAsync(b =>
                                                             b.Name == characterName && b.RealmName == realmName
                                                             );

            if (bot == null)
            {
                throw new Exception("Bot not found. Add the bot to Bot Monitor before playing.");
            }

            var instruction = await context.Instructions.SingleOrDefaultAsync(i => i.BotId == bot.Id);

            if (instruction != null)
            {
                context.Instructions.Remove(instruction);
                await context.SaveChangesAsync();

                return(Json(instruction.Command));
            }

            return(Json(null));
        }
        public async Task <IActionResult> Create(string username, string password)
        {
            var userId = await authentication.AuthenticateUser(username, password);

            await SignInAsync(HttpContext, userId);

            return(RedirectToAction("Index", "Admin"));
        }
예제 #4
0
        public void Login(string username, string password)
        {
            var isAuthenticated = _authentication.AuthenticateUser(username, password);

            if (isAuthenticated)
            {
                var user = _useRepository.Get(username);

                // do stuff...
            }
        }
 private void CheckCredentials()
 {
     if (_authenticationService.AuthenticateUser(User.Username, User.Password))
     {
         UserAuthenticated(this, new UserAuthenticatedEventArgs(User.Username));
     }
     else
     {
         UnrecognizedUser = true;
     }
 }