Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @using System.Security.Claims;
- @{
- Microsoft.Owin.IOwinContext ctx = Request.GetOwinContext();
- var usr = Request["text1"];
- if (IsPost && usr == "valid@user.com")
- {
- ctx.Authentication.SignOut(Microsoft.AspNet.Identity.DefaultAuthenticationTypes.ApplicationCookie);
- var claims = new List<Claim>();
- claims.Add(new Claim(ClaimTypes.Email, usr));
- claims.Add(new Claim(ClaimTypes.Name, var));
- var id = new ClaimsIdentity(claims, Microsoft.AspNet.Identity.DefaultAuthenticationTypes.ApplicationCookie);
- ctx.Authentication.SignIn(id);
- //FormsAuthentication.SetAuthCookie("valid@user.com", false); // Also fails
- }
- var IP = HttpContext.Current.User.Identity.IsAuthenticated.ToString();
- var text = "valid@user.com";
- }
- <!DOCTYPE html>
- <html lang="en">
- <head><title></title></head>
- <body>
- <p>Are we Logged in? <strong>@IP</strong>.</p>
- <form action="" method="post">
- <p>
- <label for="text1">First Number:</label>
- <input type="text" name="text1" value="@text" />
- <p><input type="submit" value="Add" /></p>
- </form>
- </body>
- </html>
- using Microsoft.AspNet.Identity;
- using Microsoft.Owin;
- using Microsoft.Owin.Security;
- using Microsoft.Owin.Security.Cookies;
- using Owin;
- [assembly: OwinStartup(typeof(TypeScriptHTMLApp1.Startup1))]
- namespace TypeScriptHTMLApp1
- {
- public class Startup1
- {
- public void Configuration(IAppBuilder app)
- {
- // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888
- app.UseCookieAuthentication(new CookieAuthenticationOptions
- {
- AuthenticationType =DefaultAuthenticationTypes.ApplicationCookie,
- AuthenticationMode = AuthenticationMode.Passive,
- });
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement