Esempio n. 1
0
        public async Task <IActionResult> LoginWithToken(LoginWithTokenRequest request)
        {
            Ensure.NotNull(request, "request");
            if (tokenOptions.Tokens.TryGetValue(request.Token, out var userName))
            {
                var user = await userManager.FindByNameAsync(userName);

                if (user != null)
                {
                    return(CreateJwtToken(user, true));
                }
            }

            return(NotFound());
        }
Esempio n. 2
0
        /// <summary>
        /// Logs the user asyncrouns in. No parmaeter needed because the needed data is stored in app.config
        /// </summary>
        public async void TokenLogin()
        {
            // SSL Crt (should been placed in Solution Dir with Build Option Copy always)
            //
            SslCredentials cred = new SslCredentials(File.ReadAllText("server.crt"));

            // new Channel and then a new client based on that Channel
            //
            var connectionChannel = new Channel("beta.emergencyx.de:50051", cred);
            var emx = EmergencyExplorerService.NewClient(connectionChannel);

            LoginWithTokenRequest request = new LoginWithTokenRequest {
                UserId = Convert.ToUInt32(AppConfig.readFromAppConfig("userId")), Token = AppConfig.readFromAppConfig("token")
            };
            LoginResponse response = await emx.LoginWithTokenAsync(request);

            connectionChannel.ShutdownAsync().Wait();

            if (response.Success != true)
            {
                throw new NotSuccessFullLoggedInException();
            }
        }