示例#1
0
        public WebLoginResult IniciarSesion(string username, string contrasenia)
        {
            var             result  = SingInManager.PasswordSignIn(username, contrasenia, true, false);
            bool            sesion  = result == SignInStatus.Success;
            ApplicationUser usuario = null;

            if (sesion)
            {
                usuario = context.Users.First(x => x.UserName == username);
            }
            if (!sesion)
            {
                return(new WebLoginResult
                {
                    IsLogged = false,
                    Mensaje = "Error al iniciar sesion",
                    UserName = username
                });
            }
            else
            {
                var roles = UserManager.GetRolesAsync(usuario.Id).Result;
                return(new WebLoginResult
                {
                    Mensaje = "Bienvenido " + usuario.UserName + "!",
                    IsLogged = sesion,
                    UserId = usuario.Id,
                    UserName = usuario.UserName,
                    Email = usuario.Email,
                    Rol = roles.FirstOrDefault()
                });
            }
        }
        public async Task <IActionResult> CreateVote([Bind("PhdStudentId,Voice")] Vote vote)
        {
            if (ModelState.IsValid)
            {
                Context.Add(vote);
                await Context.SaveChangesAsync();

                await SingInManager.SignOutAsync(); // пользователь выходит после голосования

                return(RedirectToAction(nameof(Index)));
            }
            return(View());
        }
        #pragma warning disable 1998
        public async override global::System.Threading.Tasks.Task ExecuteAsync()
        {
            BeginContext(38, 19, true);
            WriteLiteral("<!DOCTYPE html>\r\n\r\n");
            EndContext();
            BeginContext(124, 10, true);
            WriteLiteral("\r\n<html>\r\n");
            EndContext();
            BeginContext(134, 294, false);
            __tagHelperExecutionContext = __tagHelperScopeManager.Begin("head", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "c858e4cace8b4b460a219f0fe6e88bfb178e8e048270", async() => {
                BeginContext(140, 72, true);
                WriteLiteral("\r\n    <meta name=\"viewport\" content=\"width=device-width\" />\r\n    <title>");
                EndContext();
                BeginContext(213, 13, false);
#line 10 "G:\CShape_Study\03-Tutorial\03-Tutorial.Web\Views\Shared\_Layout.cshtml"
                Write(ViewBag.Title);

#line default
#line hidden
                EndContext();
                BeginContext(226, 12, true);
                WriteLiteral("</title>\r\n\r\n");
                EndContext();
                BeginContext(270, 4, true);
                WriteLiteral("    ");
                EndContext();
                BeginContext(274, 145, false);
                __tagHelperExecutionContext = __tagHelperScopeManager.Begin("environment", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "c858e4cace8b4b460a219f0fe6e88bfb178e8e049194", async() => {
                    BeginContext(309, 10, true);
                    WriteLiteral("\r\n        ");
                    EndContext();
                    BeginContext(319, 80, false);
                    __tagHelperExecutionContext = __tagHelperScopeManager.Begin("link", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "c858e4cace8b4b460a219f0fe6e88bfb178e8e049611", async() => {
                    }
                                                                                );
                    __Microsoft_AspNetCore_Mvc_Razor_TagHelpers_UrlResolutionTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper>();
                    __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_Razor_TagHelpers_UrlResolutionTagHelper);
                    __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_0);
                    __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_1);
                    await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
                    if (!__tagHelperExecutionContext.Output.IsContentModified)
                    {
                        await __tagHelperExecutionContext.SetOutputContentAsync();
                    }
                    Write(__tagHelperExecutionContext.Output);
                    __tagHelperExecutionContext = __tagHelperScopeManager.End();
                    EndContext();
                    BeginContext(399, 6, true);
                    WriteLiteral("\r\n    ");
                    EndContext();
                }
                                                                            );
                __Microsoft_AspNetCore_Mvc_TagHelpers_EnvironmentTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.EnvironmentTagHelper>();
                __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_EnvironmentTagHelper);
                __Microsoft_AspNetCore_Mvc_TagHelpers_EnvironmentTagHelper.Include = (string)__tagHelperAttribute_2.Value;
                __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_2);
                await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
                if (!__tagHelperExecutionContext.Output.IsContentModified)
                {
                    await __tagHelperExecutionContext.SetOutputContentAsync();
                }
                Write(__tagHelperExecutionContext.Output);
                __tagHelperExecutionContext = __tagHelperScopeManager.End();
                EndContext();
                BeginContext(419, 2, true);
                WriteLiteral("\r\n");
                EndContext();
            }
                                                                        );
            __Microsoft_AspNetCore_Mvc_Razor_TagHelpers_HeadTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper>();
            __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_Razor_TagHelpers_HeadTagHelper);
            await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);

            if (!__tagHelperExecutionContext.Output.IsContentModified)
            {
                await __tagHelperExecutionContext.SetOutputContentAsync();
            }
            Write(__tagHelperExecutionContext.Output);
            __tagHelperExecutionContext = __tagHelperScopeManager.End();
            EndContext();
            BeginContext(428, 2, true);
            WriteLiteral("\r\n");
            EndContext();
            BeginContext(430, 1936, false);
            __tagHelperExecutionContext = __tagHelperScopeManager.Begin("body", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "c858e4cace8b4b460a219f0fe6e88bfb178e8e0412898", async() => {
                BeginContext(436, 329, true);
                WriteLiteral(@"
    <h1>我是在模板文件中放置的内容</h1>
    <nav class=""navbar navbar-light bd-light"">
        <div class=""container-fluid"">
            <span class=""navbar-brand mb-0 h1"">Navbar</span>
        </div>
    </nav>

    <nav class=""navbar navbar-expand-lg navbar-light bd-light"">
        <a class=""navbar-brand"" href=""#"">Navbar</a>

");
                EndContext();
#line 29 "G:\CShape_Study\03-Tutorial\03-Tutorial.Web\Views\Shared\_Layout.cshtml"
                if (SingInManager.IsSignedIn(User))
                {
#line default
#line hidden
                    BeginContext(890, 12, true);
                    WriteLiteral("            ");
                    EndContext();
                    BeginContext(902, 307, false);
                    __tagHelperExecutionContext = __tagHelperScopeManager.Begin("form", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "c858e4cace8b4b460a219f0fe6e88bfb178e8e0413931", async() => {
                        BeginContext(983, 219, true);
                        WriteLiteral("\r\n                <ul class=\"navbar-nav mr-auto\">\r\n                    <li class=\"nav-item\">\r\n                        <a href=\"#\" onclick=\"logout()\">登出</a>\r\n                    </li>\r\n                </ul>\r\n            ");
                        EndContext();
                    }
                                                                                );
                    __Microsoft_AspNetCore_Mvc_TagHelpers_FormTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper>();
                    __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_FormTagHelper);
                    __Microsoft_AspNetCore_Mvc_TagHelpers_RenderAtEndOfFormTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.RenderAtEndOfFormTagHelper>();
                    __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_RenderAtEndOfFormTagHelper);
                    __Microsoft_AspNetCore_Mvc_TagHelpers_FormTagHelper.Controller = (string)__tagHelperAttribute_3.Value;
                    __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_3);
                    __Microsoft_AspNetCore_Mvc_TagHelpers_FormTagHelper.Action = (string)__tagHelperAttribute_4.Value;
                    __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_4);
                    __Microsoft_AspNetCore_Mvc_TagHelpers_FormTagHelper.Method = (string)__tagHelperAttribute_5.Value;
                    __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_5);
                    __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_6);
                    await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
                    if (!__tagHelperExecutionContext.Output.IsContentModified)
                    {
                        await __tagHelperExecutionContext.SetOutputContentAsync();
                    }
                    Write(__tagHelperExecutionContext.Output);
                    __tagHelperExecutionContext = __tagHelperScopeManager.End();
                    EndContext();
                    BeginContext(1209, 3, true);
                    WriteLiteral(" \r\n");
                    EndContext();
#line 39 "G:\CShape_Study\03-Tutorial\03-Tutorial.Web\Views\Shared\_Layout.cshtml"
                }
                else
                {
#line default
#line hidden
                    BeginContext(1248, 104, true);
                    WriteLiteral("            <ul class=\"navbar-nav mr-auto\">\r\n                <li class=\"nav-item\">\r\n                    ");
                    EndContext();
                    BeginContext(1352, 56, false);
                    __tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "c858e4cace8b4b460a219f0fe6e88bfb178e8e0416797", async() => {
                        BeginContext(1402, 2, true);
                        WriteLiteral("注册");
                        EndContext();
                    }
                                                                                );
                    __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper>();
                    __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper);
                    __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.Controller = (string)__tagHelperAttribute_3.Value;
                    __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_3);
                    __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.Action = (string)__tagHelperAttribute_7.Value;
                    __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_7);
                    await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
                    if (!__tagHelperExecutionContext.Output.IsContentModified)
                    {
                        await __tagHelperExecutionContext.SetOutputContentAsync();
                    }
                    Write(__tagHelperExecutionContext.Output);
                    __tagHelperExecutionContext = __tagHelperScopeManager.End();
                    EndContext();
                    BeginContext(1408, 84, true);
                    WriteLiteral("\r\n                </li>\r\n                <li class=\"nav-item\">\r\n                    ");
                    EndContext();
                    BeginContext(1492, 53, false);
                    __tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "c858e4cace8b4b460a219f0fe6e88bfb178e8e0418557", async() => {
                        BeginContext(1539, 2, true);
                        WriteLiteral("登录");
                        EndContext();
                    }
                                                                                );
                    __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper>();
                    __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper);
                    __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.Controller = (string)__tagHelperAttribute_3.Value;
                    __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_3);
                    __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.Action = (string)__tagHelperAttribute_8.Value;
                    __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_8);
                    await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
                    if (!__tagHelperExecutionContext.Output.IsContentModified)
                    {
                        await __tagHelperExecutionContext.SetOutputContentAsync();
                    }
                    Write(__tagHelperExecutionContext.Output);
                    __tagHelperExecutionContext = __tagHelperScopeManager.End();
                    EndContext();
                    BeginContext(1545, 44, true);
                    WriteLiteral("\r\n                </li>\r\n            </ul>\r\n");
                    EndContext();
#line 50 "G:\CShape_Study\03-Tutorial\03-Tutorial.Web\Views\Shared\_Layout.cshtml"
                }

#line default
#line hidden
                BeginContext(1600, 19, true);
                WriteLiteral("\r\n        <div>\r\n\r\n");
                EndContext();
                BeginContext(1666, 12, true);
                WriteLiteral("            ");
                EndContext();
                BeginContext(1679, 12, false);
#line 55 "G:\CShape_Study\03-Tutorial\03-Tutorial.Web\Views\Shared\_Layout.cshtml"
                Write(RenderBody());

#line default
#line hidden
                EndContext();
                BeginContext(1691, 183, true);
                WriteLiteral("\r\n        </div>\r\n\r\n        <hr />\r\n\r\n        <div>\r\n            <!--\r\n            指定一个渲染Section,名称叫bottom\r\n            required: false => 表示并不是一个页面都需要有这一部分\r\n        -->\r\n            ");
                EndContext();
                BeginContext(1875, 40, false);
#line 65 "G:\CShape_Study\03-Tutorial\03-Tutorial.Web\Views\Shared\_Layout.cshtml"
                Write(RenderSection("bottom", required: false));

#line default
#line hidden
                EndContext();
                BeginContext(1915, 26, true);
                WriteLiteral("\r\n        </div>\r\n        ");
                EndContext();
                BeginContext(1941, 60, false);
                __tagHelperExecutionContext = __tagHelperScopeManager.Begin("script", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "c858e4cace8b4b460a219f0fe6e88bfb178e8e0421598", async() => {
                }
                                                                            );
                __Microsoft_AspNetCore_Mvc_Razor_TagHelpers_UrlResolutionTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper>();
                __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_Razor_TagHelpers_UrlResolutionTagHelper);
                __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_9);
                await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
                if (!__tagHelperExecutionContext.Output.IsContentModified)
                {
                    await __tagHelperExecutionContext.SetOutputContentAsync();
                }
                Write(__tagHelperExecutionContext.Output);
                __tagHelperExecutionContext = __tagHelperScopeManager.End();
                EndContext();
                BeginContext(2001, 10, true);
                WriteLiteral("\r\n        ");
                EndContext();
                BeginContext(2011, 80, false);
                __tagHelperExecutionContext = __tagHelperScopeManager.Begin("script", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "c858e4cace8b4b460a219f0fe6e88bfb178e8e0422859", async() => {
                }
                                                                            );
                __Microsoft_AspNetCore_Mvc_Razor_TagHelpers_UrlResolutionTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper>();
                __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_Razor_TagHelpers_UrlResolutionTagHelper);
                __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_10);
                await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
                if (!__tagHelperExecutionContext.Output.IsContentModified)
                {
                    await __tagHelperExecutionContext.SetOutputContentAsync();
                }
                Write(__tagHelperExecutionContext.Output);
                __tagHelperExecutionContext = __tagHelperScopeManager.End();
                EndContext();
                BeginContext(2091, 10, true);
                WriteLiteral("\r\n        ");
                EndContext();
                BeginContext(2101, 104, false);
                __tagHelperExecutionContext = __tagHelperScopeManager.Begin("script", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "c858e4cace8b4b460a219f0fe6e88bfb178e8e0424122", async() => {
                }
                                                                            );
                __Microsoft_AspNetCore_Mvc_Razor_TagHelpers_UrlResolutionTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper>();
                __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_Razor_TagHelpers_UrlResolutionTagHelper);
                __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_11);
                await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
                if (!__tagHelperExecutionContext.Output.IsContentModified)
                {
                    await __tagHelperExecutionContext.SetOutputContentAsync();
                }
                Write(__tagHelperExecutionContext.Output);
                __tagHelperExecutionContext = __tagHelperScopeManager.End();
                EndContext();
                BeginContext(2205, 154, true);
                WriteLiteral("\r\n        <script>\r\n            function logout() {\r\n                document.getElementById(\"logoutForm\").submit();\r\n            }\r\n\r\n        </script>\r\n");
                EndContext();
            }
                                                                        );
            __Microsoft_AspNetCore_Mvc_Razor_TagHelpers_BodyTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper>();
            __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_Razor_TagHelpers_BodyTagHelper);
            await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);

            if (!__tagHelperExecutionContext.Output.IsContentModified)
            {
                await __tagHelperExecutionContext.SetOutputContentAsync();
            }
            Write(__tagHelperExecutionContext.Output);
            __tagHelperExecutionContext = __tagHelperScopeManager.End();
            EndContext();
            BeginContext(2366, 11, true);
            WriteLiteral("\r\n</html>\r\n");
            EndContext();
        }
示例#4
0
 public AccountController(UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager)
 {
     _userManager   = userManager;
     _signInManager = signInManager;
 }
示例#5
0
 public UsersController()
 {
     this.singInManager = new SingInManager(new NotesApplicationContext());
 }