public ActionResult Login(string user, string Apitoken, string ReturnURL)
        {
            var userAPI = new Core.API.User (CacheProvider, LogProvider);
            userAPI.Authenticate (new Core.Models.GithubUser { Name = user, APIToken = Apitoken });
            try
            {
                var privateuser = userAPI.Get ();
                if (privateuser == null)
                    throw new Exception ("Invalid user");

                CurrentUser = new Core.Models.GithubUser { Name = user, APIToken = Apitoken };

                SetTemporaryNotification ("Login succeded");

                if (Request.IsAjaxRequest ())
                    return Json (new { success = true, Name = user });
                if (string.IsNullOrEmpty (ReturnURL))
                    return View ("Index");
                return Redirect (ReturnURL);
            }
            catch (Exception error)
            {
                if (Request.IsAjaxRequest ())
                    return Json (new { success = false, message = error.Message });
                return View (GetBaseView (new LoginViewModel { Message = error.Message, ReturnURL = ReturnURL }));
            }
        }
        protected virtual bool Authenticate()
        {
            var userAPI = new Core.API.User(CacheProvider, LogProvider);

            userAPI.Authenticate(CurrentUser);
            try
            {
                return(userAPI.Get() != null);
            }
            catch (Exception error)
            {
                if (LogProvider.HandleAndReturnIfToThrowError(error))
                {
                    throw;
                }
                return(false);
            }
        }
        public ActionResult Login(string user, string Apitoken, string ReturnURL)
        {
            var userAPI = new Core.API.User(CacheProvider, LogProvider);

            userAPI.Authenticate(new Core.Models.GithubUser {
                Name = user, APIToken = Apitoken
            });
            try
            {
                var privateuser = userAPI.Get();
                if (privateuser == null)
                {
                    throw new Exception("Invalid user");
                }

                CurrentUser = new Core.Models.GithubUser {
                    Name = user, APIToken = Apitoken
                };

                SetTemporaryNotification("Login succeded");

                if (Request.IsAjaxRequest())
                {
                    return(Json(new { success = true, Name = user }));
                }
                if (string.IsNullOrEmpty(ReturnURL))
                {
                    return(View("Index"));
                }
                return(Redirect(ReturnURL));
            }
            catch (Exception error)
            {
                if (Request.IsAjaxRequest())
                {
                    return(Json(new { success = false, message = error.Message }));
                }
                return(View(GetBaseView(new LoginViewModel {
                    Message = error.Message, ReturnURL = ReturnURL
                })));
            }
        }