Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User is never signed in #25

Closed
Frankofoedu opened this issue Sep 4, 2019 · 6 comments
Closed

User is never signed in #25

Frankofoedu opened this issue Sep 4, 2019 · 6 comments
Labels
bug Something isn't working

Comments

@Frankofoedu
Copy link

Describe the bug
var currentUser = await _userManager.GetUserAsync(User); returns null on sign in

To Reproduce
Steps to reproduce the behavior:

  1. Login or sign up new account
  2. Page redirects to Home page without signing

Expected behavior
User should be signed in.

@amoraitis amoraitis added bug Something isn't working up-for-grabs labels Sep 4, 2019
@amoraitis
Copy link
Owner

amoraitis commented Sep 4, 2019

@Frankofoedu Thanks, for reporting this bug.

I was able to sign in and signup(Ensure that your development environment is ready to run the app). It seems that there is an exception at EmailSender service because there is no SendGrid API key to use. Although, you can still sign in with the user you created with the registration form.

Solution

We should update the module to bypass this in a development environment.

  • First, we should check if a SendGrid API key is set in the configuration.

  • If it's set go ahead and send the email.

  • If not, log an error, and exit the method(Don't try to send an email at all).

Let me know if you are able to work on this, or if you want further clarification.
This moved to a new issue #26

@Frankofoedu
Copy link
Author

I guess i want clear with my initial report. I signed up normally and received the email. When i clicked the link, i was redirected to localhost. The bug occurs when i close my dev environment and restart the app. The sign in process works as you can see below
TodoList (Debugging) - Microsoft Visual Studio 9_4_2019 4_01_43 PM

but when it goes to the home controller and checks for signed in user, it returns null
TodoList (Debugging) - Microsoft Visual Studio 9_4_2019 4_02_04 PM - Copy

. I attached screenshots. If you need more explanation, i would be glad to help

@amoraitis
Copy link
Owner

amoraitis commented Sep 4, 2019

@Frankofoedu I wasn't able to reproduce this bug. Could you please tell me which environment are you running in?
development, production or IIS?
Run it in Development environment and tell me if you get any (database) error in the console, while you are registering the user
Also, make sure that you are using the right credentials(Just in case).

@Frankofoedu
Copy link
Author

Frankofoedu commented Sep 4, 2019

I changed the project setting to run on iis but i havent been able to get it to start. It keeps saying 'unable to connect to web server IIS Express'.

I close the solutiion , then delete the .vs folder, change the ports in the appsettings.json file and reopen the solution.

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:63543",
      "sslPort": 3456
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "launchUrl": "http://localhost:63543",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Developement"
      }
    },
    "TodoList.Web": {
      "commandName": "Project",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "applicationUrl": "http://localhost:63543/"
    },
    "TodoList.Web(Production)": {
      "commandName": "Project",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Production"
      },
      "applicationUrl": "http://localhost:63543/"
    }
  }
}

I get a new error message
System.IO.FileNotFoundException: 'The configuration file 'appsettings.Developement.json' was not found and is not optional. The physical path is 'C:\Users\Frank\Source\Repos\TodoList\TodoList.Web\appsettings.Developement.json'.'

@Frankofoedu
Copy link
Author

Frankofoedu commented Sep 4, 2019

To bypass the filenotfounderror, i had to comment out a line in the startup.cs constructor

 public Startup(IHostingEnvironment environment)
        {
            Configuration = new ConfigurationBuilder()
            .SetBasePath(environment.ContentRootPath)
            .AddJsonFile("appsettings.json", false, true)
           // .AddJsonFile($"appsettings.{environment.EnvironmentName}.json")
            .AddEnvironmentVariables()
            .AddUserSecrets<Startup>()
            .Build();
            Environment = environment;
        }

This now finally runs the project but without the css and js files

@amoraitis
Copy link
Owner

To bypass the filenotfounderror, i had to comment out a line in the startup.cs constructor

 public Startup(IHostingEnvironment environment)
        {
            Configuration = new ConfigurationBuilder()
            .SetBasePath(environment.ContentRootPath)
            .AddJsonFile("appsettings.json", false, true)
           // .AddJsonFile($"appsettings.{environment.EnvironmentName}.json")
            .AddEnvironmentVariables()
            .AddUserSecrets<Startup>()
            .Build();
            Environment = environment;
        }

This now finally runs the project but without the css and js files

Why should you have to change all of these, in order to run it? It's easy to run the app, you don't need to choose IIS if you haven't installed it on your machine. Kestrel will run your app. You just click run, right after you cloned it.

Also, how running on IIS will help you find out why the user is not found? Please explain me why do you have to do all of these? I m closing this, because its off topic. If you cannot setup the project, just contact me at twitter: amoraitis_me or email: anas.moraitis@gmail.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants