You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: SimpleBlog/Controllers/AuthController.cs
+13-7Lines changed: 13 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -3,31 +3,37 @@
3
3
usingSystem.Linq;
4
4
usingSystem.Web;
5
5
usingSystem.Web.Mvc;
6
+
usingSystem.Web.Security;
6
7
usingSimpleBlog.ViewModels;
7
8
8
9
namespaceSimpleBlog.Controllers
9
10
{
10
11
publicclassAuthController:Controller
12
+
11
13
{
14
+
publicActionResultLogout()
15
+
{
16
+
FormsAuthentication.SignOut();
17
+
returnRedirectToRoute("home");
18
+
}
12
19
// GET: Auth
13
20
publicActionResultLogin()
14
21
{
15
22
returnView(newAuthLogin{});
16
23
}
17
24
18
25
[HttpPost]
19
-
publicActionResultLogin(AuthLoginform)
26
+
publicActionResultLogin(AuthLoginform,stringreturnUrl)// the string returnUrl redirects the user to where they want to go if they sign in successfully.
20
27
{
21
28
if(!ModelState.IsValid)//This tells mvc what to do if the required fields in the model(auth.cs) are invalid.
22
29
returnView(form);// the form parameter here means retrun the form as it was submitted(the post request).
23
30
24
-
if(form.UserName!="dylan riley")
25
-
{
26
-
ModelState.AddModelError("UserName","Your username proves to me that you are not a boss!");
<ahref="@Url.Action("index", "Posts", new { area = "admin"})">Viewpostsinadmin</a><!--thereasoniputnew {area="admin"} isbecausetheoverloadrequiresanobject-->
0 commit comments