Beispiel #1
0
        public HttpResponseMessage <bool> Login(HttpRequestMessage request)
        {
            var connectionstring = System.Configuration.ConfigurationManager.ConnectionStrings["EarthwatchersConnection"].ConnectionString;
            var isOkay           = Authenticator.Authenticate(connectionstring);

            if (isOkay)
            {
                //Guardo un nuevo Scoring
                ScoreRepository scoreRepository = new ScoreRepository(connectionstring);
                scoreRepository.AddLoginScore(System.Web.HttpContext.Current.User.Identity.Name);

                if (!Session.HasLoggedUser())
                {
                    EarthwatcherRepository ewRepo = new EarthwatcherRepository(connectionstring);
                    var ew = ewRepo.GetEarthwatcher(System.Web.HttpContext.Current.User.Identity.Name, false);
                    if (ew != null)
                    {
                        Session.GenerateCookie(ew);
                    }
                }

                return(new HttpResponseMessage <bool>(isOkay)
                {
                    StatusCode = HttpStatusCode.OK
                });
            }
            else
            {
                return(new HttpResponseMessage <bool>(isOkay)
                {
                    StatusCode = HttpStatusCode.Forbidden
                });
            }
        }