Ejemplo n.º 1
0
        // Authenticates an API user with the given token for a cross instance login
        public async Task <IActionResult> ApiCrossLogin(string address, string token)
        {
            // Returns if token or address is null
            if (address == null || token == null)
            {
                return(Redirect("/"));
            }

            // Retrieves token, returning if invalid
            TempApiToken tempApiToken = await _repository.GetTempApiToken(token);

            if (tempApiToken == null)
            {
                return(Unauthorized());
            }

            // Signs in user
            IActionResult returnResult = RedirectToAction("CrossLogin", new
            {
                address,
                type = "api"
            });

            return(await SignInUser(tempApiToken.User, returnResult));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> GenerateTempToken()
        {
            User user = await _repository.GetUserAsync(User);

            TempApiToken token = await _repository.AddTempApiToken(user);

            await _repository.SaveChangesAsync();

            return(Ok(token.Token));
        }