public HttpResponseMessage LogAnonymous(ServicesAction action) { Services services = new Services(); services.Log(action); return(Request.CreateResponse(HttpStatusCode.OK)); }
public HttpResponseMessage Host(ServicesAction action) { action.LogTypeKey = "LOGIN_SUPERUSER"; Services services = new Services(); services.Log(action); return(Request.CreateResponse(HttpStatusCode.OK)); }
public ActionResult Login(Authentication credentials) { //login credentials.Cookies = new CookieContainer(); string url = DnnServices.GetUrl(credentials.DnnHttpAlias, "Services", "Auth", "Login", false); string errorMsg = null; HttpStatusCode statusCode; CookieContainer cookies = credentials.Cookies; ServicesAction action = new ServicesAction(); action.AppName = "DnnMvcMobile"; action.LogServerName = System.Environment.MachineName; action.LogTypeKey = "LOGIN_FAILURE"; //default for this action action.Username = credentials.Username; string body = JsonConvert.SerializeObject(action); string response = DnnServices.PostRequest(url, credentials.Username, credentials.Password, body, out statusCode, out errorMsg, ref cookies); if (statusCode == HttpStatusCode.OK) { FormsAuthentication.SetAuthCookie(credentials.Username, false); //deserialize response ServicesUser servicesUser = new ServicesUser(); servicesUser = JsonConvert.DeserializeObject <ServicesUser>(response); //TODO servicesUser data handling, at least UserID return(RedirectToAction("Index", "Account")); } else { switch (statusCode) { case HttpStatusCode.Unauthorized: case HttpStatusCode.Forbidden: ViewBag.Message = errorMsg; //post LOGIN_FAILURE to event log url = DnnServices.GetUrl(credentials.DnnHttpAlias, "Services", "Log", "LogAnonymous", false); DnnServices.PostRequest(url, credentials.Username, credentials.Password, body, out statusCode, out errorMsg, ref cookies); ViewBag.Message += " " + errorMsg; break; default: //something else entirely! ViewBag.Message = "<li>Please contact the system administrator for http://" + credentials.DnnHttpAlias + "</li><li>Http Status: " + statusCode.ToString() + "</li><li>Error Message: " + errorMsg + "</li>"; break; } return(View()); } }
public void Log(ServicesAction action) { EventLogController eventLog = new EventLogController(); DotNetNuke.Services.Log.EventLog.LogInfo logInfo = default(DotNetNuke.Services.Log.EventLog.LogInfo); logInfo = new LogInfo(); logInfo.LogUserName = action.Username; logInfo.LogPortalID = PortalId; logInfo.LogTypeKey = action.LogTypeKey; logInfo.LogServerName = action.LogServerName; logInfo.AddProperty("Requested By", action.AppName); //logInfo.AddProperty("PropertyName2", propertyValue2); eventLog.AddLog(logInfo); }
public HttpResponseMessage Login(ServicesAction action) { Services services = new Services(); ServicesUser servicesUser = services.GetUserByName(action.Username); if (servicesUser.IsSuperUser) { return(Host(action)); } else { action.LogTypeKey = "LOGIN_SUCCESS"; services.Log(action); return(Request.CreateResponse(HttpStatusCode.OK)); } }