O'Reilly logo

Mastering Internet of Things by Peter Waher

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Redirecting the user

Now that we have the credentials, we need to check them against our user database. We will define a method for this, bool Login(UserName, Password), returning whether the credentials were authenticated or not. If successful, we set the session variable User, which we defined in the Markdown documents, to the corresponding user object. This tells the application that the user is logged in, and will stay logged in, while the session is maintained:

IUser User = this.Login(UserName, Password); if (User != null) { Log.Informational("User logged in.", UserName, req.RemoteEndPoint, "LoginSuccessful", EventLevel.Minor); req.Session["User"] = User; req.Session.Remove("LoginError"); throw new SeeOtherException(From); } else { Log.Warning("Invalid ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required