public override void OnActionExecuting(ActionExecutingContext filterContext) { var user = HttpContext.Session.GetObjectFromJson <Domain.Socioboard.Models.User>("User"); var session = HttpContext.Session.GetObjectFromJson <Domain.Socioboard.Models.SessionHistory>("revokedata"); if (session != null) { var requestParameters = new SortedDictionary <string, string> { { "systemId", session.systemId } }; var httpWebRequest = CustomHttpWebRequest.HttpWebRequest("POST", "/api/User/checksociorevtoken", requestParameters, _appSettings.ApiDomain); if (httpWebRequest != "false") { SetSession(user); } else { HttpContext.Session.Remove("User"); HttpContext.Session.Remove("selectedGroupId"); HttpContext.Session.Clear(); HttpContext.Session.Remove("revokedata"); } } else { if (Request.Cookies["sociorevtoken"] != null) { var socioRevToken = PluginHelper.Base64Decode(Request.Cookies["sociorevtoken"]); var requestParameters = new SortedDictionary <string, string> { { "systemId", socioRevToken } }; var httpWebRequest = CustomHttpWebRequest.HttpWebRequest("POST", "/api/User/checksociorevtoken", requestParameters, _appSettings.ApiDomain); if (httpWebRequest != "false") { SetSession(user); } } } base.OnActionExecuting(filterContext); }
private void SetSession(Domain.Socioboard.Models.User currentLoggedInUser) { if (currentLoggedInUser != null) { return; } var emailId = string.Empty; var password = string.Empty; if (Request.Cookies["socioboardemailId"] != null) { emailId = PluginHelper.Base64Decode(Request.Cookies["socioboardemailId"]); } if (string.IsNullOrEmpty(emailId)) { return; } if (Request.Cookies["socioboardToken"] != null) { password = PluginHelper.Base64Decode(Request.Cookies["socioboardToken"]); } var requestParameters = new SortedDictionary <string, string> { { "UserName", emailId }, { "Password", string.IsNullOrEmpty(password) ? "sociallogin" : password } }; var response = CustomHttpWebRequest.HttpWebRequest("POST", "/api/User/CheckUserLogin", requestParameters, _appSettings.ApiDomain); if (string.IsNullOrEmpty(response)) { return; } var user = Newtonsoft.Json.JsonConvert.DeserializeObject <Domain.Socioboard.Models.User>(response); HttpContext.Session.SetObjectAsJson("User", user); }
public async Task <IActionResult> SBApp(string profileType, string url, string content, string imageUrl, string name, string userImage, string screenName, string tweet, string tweetId, string type, string EmailId) { var password = ""; var pluginData = new Domain.Socioboard.Helpers.PluginData { profileType = profileType, content = content, imageUrl = imageUrl, name = name, screenName = screenName, tweet = tweet, tweetId = tweetId, url = url, userImage = userImage, type = type }; if (!string.IsNullOrEmpty(imageUrl)) { if (imageUrl.Equals(url)) { if (type == "timeline-image") { pluginData.url = string.Empty; } if (profileType == "image") { pluginData.url = string.Empty; } } } if (profileType == "website") { if (url.Contains(".jpg") || url.Contains(".png")) { pluginData.imageUrl = url; pluginData.url = string.Empty; } } var user = HttpContext.Session.GetObjectFromJson <Domain.Socioboard.Models.User>("User"); if (user == null) { if (Request.Cookies["socioboardpluginemailId"] != null) { EmailId = Request.Cookies["socioboardpluginemailId"]; EmailId = PluginHelper.Base64Decode(EmailId); } if (Request.Cookies["socioboardpluginToken"] != null) { password = Request.Cookies["socioboardpluginToken"]; password = PluginHelper.Base64Decode(password); } if (!string.IsNullOrEmpty(EmailId) && !string.IsNullOrEmpty(password)) { var parameters = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("UserName", EmailId), new KeyValuePair <string, string>("Password", password) }; var loginResponse = await WebApiReq.PostReq("/api/User/CheckUserLogin", parameters, "", "", _appSettings.ApiDomain); if (loginResponse.IsSuccessStatusCode) { try { user = await loginResponse.Content.ReadAsAsync <Domain.Socioboard.Models.User>(); HttpContext.Session.SetObjectAsJson("User", user); } catch (Exception e) { _logger.LogError(e.Message); } } else { ViewBag.User = "******"; return(View("Rlogin")); } } } if (user == null) { return(View("Rlogin")); } if (!string.IsNullOrEmpty(url) && profileType != "pinterest") { var plugindata = PluginHelper.CreateThumbnail(url); pluginData._ThumbnailDetails = plugindata; } ViewBag.plugin = pluginData; ViewBag.emailId = user.EmailId; ViewBag.password = user.Password; ViewBag.userId = user.Id.ToString(); var response = await WebApiReq.GetReq("/api/Groups/GetUserGroups?userId=" + user.Id, "", "", _appSettings.ApiDomain); if (!response.IsSuccessStatusCode) { return(View("Rlogin")); } try { var groups = await response.Content.ReadAsAsync <List <Domain.Socioboard.Models.Groups> >(); var selectedGroupId = groups.FirstOrDefault(t => t.groupName == Domain.Socioboard.Consatants.SocioboardConsts.DefaultGroupName)?.id; if (selectedGroupId != null) { var pluginProfileResponse = await WebApiReq.GetReq("/api/GroupProfiles/GetPluginProfile?groupId=" + selectedGroupId, "", "", _appSettings.ApiDomain); if (pluginProfileResponse.IsSuccessStatusCode) { try { var pluginProfiles = await pluginProfileResponse.Content.ReadAsAsync <List <Domain.Socioboard.Helpers.PluginProfile> >(); return(View("RMain", pluginProfiles)); } catch (Exception e) { _logger.LogError(e.Message); } } } } catch (Exception e) { _logger.LogError(e.Message); } return(View("Rlogin")); }
public async Task <IActionResult> SBApp(string profileType, string url, string content, string imageUrl, string name, string userImage, string screenName, string tweet, string tweetId, string type, string EmailId) { string password = ""; Domain.Socioboard.Helpers.PluginData _PluginData = new Domain.Socioboard.Helpers.PluginData(); _PluginData.profileType = profileType; _PluginData.content = content; _PluginData.imageUrl = imageUrl; _PluginData.name = name; _PluginData.screenName = screenName; _PluginData.tweet = tweet; _PluginData.tweetId = tweetId; _PluginData.url = url; _PluginData.userImage = userImage; _PluginData.type = type; Domain.Socioboard.Models.User user = HttpContext.Session.GetObjectFromJson <Domain.Socioboard.Models.User>("User"); if (user == null) { if (Request.Cookies["socioboardpluginemailId"] != null) { EmailId = Request.Cookies["socioboardpluginemailId"].ToString(); EmailId = PluginHelper.Base64Decode(EmailId); } if (Request.Cookies["socioboardpluginToken"] != null) { password = Request.Cookies["socioboardpluginToken"].ToString(); password = PluginHelper.Base64Decode(password); } if (!string.IsNullOrEmpty(EmailId) && !string.IsNullOrEmpty(password)) { List <KeyValuePair <string, string> > Parameters = new List <KeyValuePair <string, string> >(); Parameters.Add(new KeyValuePair <string, string>("UserName", EmailId)); Parameters.Add(new KeyValuePair <string, string>("Password", password)); HttpResponseMessage _response = await WebApiReq.PostReq("/api/User/CheckUserLogin", Parameters, "", "", _appSettings.ApiDomain); if (_response.IsSuccessStatusCode) { try { user = await _response.Content.ReadAsAsync <Domain.Socioboard.Models.User>(); HttpContext.Session.SetObjectAsJson("User", user); } catch { } } else { ViewBag.User = "******"; return(View("Rlogin")); } } } if (user != null) { if (!string.IsNullOrEmpty(url) && profileType != "pinterest") { Domain.Socioboard.Helpers.ThumbnailDetails plugindata = PluginHelper.CreateThumbnail(url); _PluginData._ThumbnailDetails = plugindata; } ViewBag.plugin = _PluginData; ViewBag.emailId = user.EmailId; ViewBag.password = user.Password; HttpResponseMessage response = await WebApiReq.GetReq("/api/Groups/GetUserGroups?userId=" + user.Id, "", "", _appSettings.ApiDomain); if (response.IsSuccessStatusCode) { try { List <Domain.Socioboard.Models.Groups> groups = await response.Content.ReadAsAsync <List <Domain.Socioboard.Models.Groups> >(); long selectedGroupId = groups.FirstOrDefault(t => t.groupName == Domain.Socioboard.Consatants.SocioboardConsts.DefaultGroupName).id; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >(); parameters.Add(new KeyValuePair <string, string>("userId", user.Id.ToString())); HttpResponseMessage _response = await WebApiReq.GetReq("/api/GroupProfiles/GetPluginProfile?groupId=" + selectedGroupId, "", "", _appSettings.ApiDomain); if (_response.IsSuccessStatusCode) { try { List <Domain.Socioboard.Helpers.PluginProfile> lstsb = new List <Domain.Socioboard.Helpers.PluginProfile>(); lstsb = await _response.Content.ReadAsAsync <List <Domain.Socioboard.Helpers.PluginProfile> >(); return(View("RMain", lstsb)); } catch { } } } catch { } } } return(View("Rlogin")); }