Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HiveStatistics/sources/HeuristicLab.Services.Hive.Statistics/3.3/Controllers/AccountController.cs @ 11252

Last change on this file since 11252 was 9646, checked in by pfleck, 12 years ago

#2063:
Changed year in headers from 2012 to 2013.
Minor reformattings in chart helpers.
Refactored and simplified some statistics generator methods.

File size: 2.2 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System.Web.Mvc;
23using System.Web.Security;
24using HeuristicLab.Services.Hive.Statistics.Models;
25
26namespace HeuristicLab.Services.Hive.Statistics.Controllers {
27  [Authorize]
28  public class AccountController : Controller {
29    //
30    // GET: /Account/Login
31
32    [AllowAnonymous]
33    public ActionResult Login(string returnUrl) {
34      ViewBag.ReturnUrl = returnUrl;
35      return View();
36    }
37
38    //
39    // POST: /Account/Login
40
41    [HttpPost]
42    [AllowAnonymous]
43    [ValidateAntiForgeryToken]
44    public ActionResult Login(LoginModel model, string returnUrl) {
45      if (ModelState.IsValid && Membership.ValidateUser(model.UserName, model.Password)) {
46        FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
47        return RedirectToLocal(returnUrl);
48      }
49
50      // If we got this far, something failed, redisplay form
51      ModelState.AddModelError("", "The user name or password provided is incorrect.");
52      return View(model);
53    }
54
55    //
56    // POST: /Account/LogOff
57
58    [HttpPost]
59    [ValidateAntiForgeryToken]
60    public ActionResult LogOff() {
61      FormsAuthentication.SignOut();
62
63      return RedirectToAction("Index", "Home");
64    }
65
66    private ActionResult RedirectToLocal(string returnUrl) {
67      if (Url.IsLocalUrl(returnUrl)) {
68        return Redirect(returnUrl);
69      }
70      return RedirectToAction("Index", "Home");
71    }
72  }
73}
Note: See TracBrowser for help on using the repository browser.