public async Task <IActionResult> Edit(int id, [Bind("Id,userName,email,profilePicUrl,friendsEmail")] SocialModel socialModel) { if (id != socialModel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(socialModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SocialModelExists(socialModel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(socialModel)); }
public ActionResult CommentList(SocialModel socialService) { var comments = new CommentModel(); var options = new NameValueCollection { { "PageSize", "25" }, { "SortBy", "CreatedUtcDate" }, { "SortOrder", "Ascending" } }; if (!string.IsNullOrEmpty(socialService.Url)) { comments.Url = socialService.Url; options.Add("ContentUrl", socialService.Url); } else { comments.ContentId = socialService.ContentId; comments.ContentTypeId = socialService.ContentTypeId; options.Add("ContentId", socialService.ContentId); } comments.Results = Get(Endpoints.CommentsJson, options); return(PartialView("_commentService", comments)); }
public async Task <bool> SocialLoginFacebook() { try { FbAccessToken token = await Xamarin.Forms.DependencyService.Get <IFacebookLogin>().LogIn(permissions); if (token != null) { // save token await token.Save(); IGraphRequest request = Xamarin.Forms.DependencyService.Get <IGraphRequest>().NewRequest(token, "/me", parameters); IGraphResponse response = await request.ExecuteAsync(); SocialModel socialModel = GetFBData(JObject.Parse(response.RawResponse)); socialModel.AuthType = AuthType.Facebook; await RegisterAndUpdate(socialModel); return(true); } else { System.Diagnostics.Debug.WriteLine("======================token was null"); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.ToString()); } return(false); }
public async Task <Result <SocialModel> > FacebookValidateToken(dynamic data) { SocialModel model; try { string token = data.accessToken; HttpResponseMessage response = await client.GetAsync(_settings.GraphFacebook + data.userID + "?access_token=" + token); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); CallBackSocialModel facebook = JsonConvert.DeserializeObject <CallBackSocialModel>(responseBody); if (String.IsNullOrEmpty(facebook.error)) { model = new SocialModel(); model.Email = data.email; model.Name = data.name; model.Picture = data.picture.data.url; } else { return(_result.Create <SocialModel>(false, _errors.NotAuthorized, null)); } } catch (Exception) { return(_result.Create <SocialModel>(false, _errors.NotAuthorized, null)); } return(_result.Create(true, "", model)); }
public async Task <Result <SocialModel> > MicrosoftValidateToken(dynamic data) { SocialModel model; try { string token = data.accessToken; client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); HttpResponseMessage response = await client.GetAsync(_settings.GraphMicrosoft); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); CallBackSocialModel microsoft = JsonConvert.DeserializeObject <CallBackSocialModel>(responseBody); if (String.IsNullOrEmpty(microsoft.error)) { model = new SocialModel(); model.Email = data.account.userName; model.Name = data.account.name; } else { return(_result.Create <SocialModel>(false, _errors.NotAuthorized, null)); } } catch (Exception) { return(_result.Create <SocialModel>(false, _errors.NotAuthorized, null)); } return(_result.Create(true, "", model)); }
public ActionResult Andophael(SocialModel model) { var filename = "wwwroot/Documents/andophael.md"; model.andophael_text = cls_markdown.ConvertMDtoTXT(filename); return(View(model)); }
public async Task <Result <SocialModel> > GoogleValidateToken(dynamic data) { SocialModel model; try { var valid = true; string token = data.tokenId; token = token.Replace("{", string.Empty); token = token.Replace("}", string.Empty); Payload payload = await ValidateAsync(token, new ValidationSettings { Audience = new[] { _settings.GoogleClientId } }); if (!payload.Audience.Equals(_settings.GoogleClientId)) { valid = false; } if (!payload.Issuer.Equals(_settings.GoogleISSUER) && !payload.Issuer.Equals("https://" + _settings.GoogleISSUER)) { valid = false; } if (payload.ExpirationTimeSeconds == null) { valid = false; } else { DateTime now = DateTime.Now.ToUniversalTime(); DateTime expiration = DateTimeOffset.FromUnixTimeSeconds((long)payload.ExpirationTimeSeconds).DateTime; if (now > expiration) { valid = false; } } if (!valid) { return(_result.Create <SocialModel>(false, _errors.NotAuthorized, null)); } model = new SocialModel(); model.Email = payload.Email; model.Name = payload.Name; model.Picture = payload.Picture; } catch (Exception) { return(_result.Create <SocialModel>(false, _errors.NotAuthorized, null)); } return(_result.Create(true, "", model)); }
public async Task <IActionResult> Create([Bind("Id,userName,email,profilePicUrl,friendsEmail")] SocialModel socialModel) { if (ModelState.IsValid) { _context.Add(socialModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(socialModel)); }
/// <summary> /// Prepare the social model /// </summary> /// <returns>Social model</returns> public virtual SocialModel PrepareSocialModel() { var model = new SocialModel { FacebookLink = _storeInformationSettings.FacebookLink, TwitterLink = _storeInformationSettings.TwitterLink, YoutubeLink = _storeInformationSettings.YoutubeLink, WorkingLanguageId = _workContext.WorkingLanguage.Id, NewsEnabled = _newsSettings.Enabled, }; return(model); }
/// <summary> /// Prepare the social model /// </summary> /// <returns>Social model</returns> public virtual SocialModel PrepareSocialModel() { var model = new SocialModel { FacebookLink = _siteInformationSettings.FacebookLink, TwitterLink = _siteInformationSettings.TwitterLink, YoutubeLink = _siteInformationSettings.YoutubeLink, GooglePlusLink = _siteInformationSettings.GooglePlusLink, WorkingLanguageId = _workContext.WorkingLanguage.Id, }; return(model); }
/// <summary> /// Prepare the social model /// </summary> /// <returns>Social model</returns> public virtual async Task <SocialModel> PrepareSocialModelAsync() { var model = new SocialModel { FacebookLink = _storeInformationSettings.FacebookLink, TwitterLink = _storeInformationSettings.TwitterLink, YoutubeLink = _storeInformationSettings.YoutubeLink, WorkingLanguageId = (await _workContext.GetWorkingLanguageAsync()).Id, NewsEnabled = _newsSettings.Enabled, }; return(model); }
public virtual ActionResult Social() { var socialSetting = IocHelper.Resolve <SocialSetting>(); var model = new SocialModel() { FacebookLink = socialSetting.FacebookLink, GooglePlusLink = socialSetting.GooglePlusLink, TwitterLink = socialSetting.TwitterLink, YoutubeLink = socialSetting.YoutubeLink }; return(PartialView(model)); }
private async Task <Result <LoginDto> > SocialSave(SocialModel modelSocial, HttpRequest request) { UserPrivateDataModel model = new UserPrivateDataModel(); var register = await _services.Register(modelSocial.id, modelSocial.Email, _crypto.GetRandomNumber(), true); if (!register.Success) { if (register.Message != _errors.Found) { return(_result.Create <LoginDto>(false, register.Message, null)); } else { var found = await _services.GetSecrets(register.Value); if (!found.Success) { return(_result.Create <LoginDto>(false, found.Message, null)); } if (found.Value.Block) { return(_result.Create <LoginDto>(true, _errors.NotAuthorized, null)); } model.id = found.Value.id; model.Email = found.Value.Email; model.ValidEmail = found.Value.ValidEmail; model.Scopes = found.Value.Scopes; model.Tenants = found.Value.Tenants; model.Block = found.Value.Block; } } else { model.id = register.Value; model.Email = modelSocial.Email; model.ValidEmail = true; model.Scopes = modelSocial.Scopes; model.Tenants = modelSocial.Tenants; await UpdateScopes(model.id, model.Scopes); await UpdateTenants(model.id, model.Tenants); } var dataResult = GetToken(model); var login = EndToken(request, _settingsTokens.CookieToken, _settingsSecrets.CookieTokenPath, dataResult.Value); return(_result.Create <LoginDto>(true, "", login)); }
private async Task RegisterAndUpdate(SocialModel model) { //Need to check if they have changed their name and want it changed try { UserDto userDto = null; if (!String.IsNullOrEmpty(model.Id)) { userDto = await CurrentApp.MainViewModel.ServiceApi.GetUserBySocial(model.Id, model.AuthType); if (userDto != null) { Helpers.Settings.Current.UserGuid = userDto.ID; } } if (userDto == null || model.Name != userDto.UserName || model.Id != userDto.SocialID || model.Email != userDto.Email || model.AvatarUrl != userDto.AvatarUrl) { Helpers.Settings.Current.UserFirstName = model.Name; Helpers.Settings.Current.UserName = model.Name; Helpers.Settings.Current.SocialUserID = model.Id; Helpers.Settings.Current.UserEmail = model.Email; Helpers.Settings.Current.AvatarUrl = model.AvatarUrl; Helpers.Settings.Current.UserAuth = model.AuthType; //This is what not we have saved on the server await GetOrCreate(false); } else if (model.Name != Helpers.Settings.Current.UserFirstName || model.Id != Helpers.Settings.Current.SocialUserID || model.Email != Helpers.Settings.Current.UserEmail || model.AvatarUrl != Helpers.Settings.Current.AvatarUrl) { //Deleted the app Helpers.Settings.Current.UserFirstName = model.Name; Helpers.Settings.Current.UserName = model.Name; Helpers.Settings.Current.SocialUserID = model.Id; Helpers.Settings.Current.UserEmail = model.Email; Helpers.Settings.Current.AvatarUrl = model.AvatarUrl; Helpers.Settings.Current.UserAuth = model.AuthType; } } catch (Exception) { } return; }
private async Task <SocialModel> GetTwitterData() { SocialModel model = new SocialModel(); var account = AccountStore.Create().FindAccountsForService(AccountServiceTwitter).FirstOrDefault(); var auth = new LinqToTwitter.SingleUserAuthorizer { CredentialStore = new SingleUserInMemoryCredentialStore { ConsumerKey = "FWinTbxeDRfqL6pd6TyvBWqvY", ConsumerSecret = "vqHOpCafR8eNNy140xfNRy80W2zyN0A4whM9lcVWj9oSPalDAz", AccessToken = account.Properties["oauth_token"], AccessTokenSecret = account.Properties["oauth_token_secret"], } }; var twitterCtx = new LinqToTwitter.TwitterContext(auth); try { var verifyResponse = await (from acct in twitterCtx.Account where acct.Type == LinqToTwitter.AccountType.VerifyCredentials && (acct.IncludeEmail == true) select acct) .SingleOrDefaultAsync(); if (verifyResponse != null && verifyResponse.User != null) { LinqToTwitter.User user = verifyResponse.User; model.Email = user.Email; model.Id = user.UserIDResponse; model.AvatarUrl = user.ProfileImageUrl.Replace("normal", "bigger"); model.AuthType = AuthType.Twitter; if (!String.IsNullOrEmpty(user.Name)) { model.Name = user.Name; } else if (!String.IsNullOrEmpty(user.ScreenNameResponse)) { model.Name = user.ScreenNameResponse; } return(model); } } catch (LinqToTwitter.TwitterQueryException) { } return(model); }
public async Task <bool> HandleAlreadyLoggedIn(FbAccessToken token) { IGraphRequest request = Xamarin.Forms.DependencyService.Get <IGraphRequest>().NewRequest(token, "/me", parameters); IGraphResponse response = await request.ExecuteAsync(); if (response.RawResponse != null) { SocialModel socialModel = GetFBData(JObject.Parse(response.RawResponse)); socialModel.AuthType = AuthType.Facebook; await RegisterAndUpdate(socialModel); return(true); } return(false); }
public ActionResult Social() { //model var model = new SocialModel { FacebookLink = _storeInformationSettings.FacebookLink, TwitterLink = _storeInformationSettings.TwitterLink, YoutubeLink = _storeInformationSettings.YoutubeLink, GooglePlusLink = _storeInformationSettings.GooglePlusLink, WorkingLanguageId = _workContext.WorkingLanguage.Id, NewsEnabled = _newsSettings.Enabled, }; return(PartialView(model)); }
public IViewComponentResult Invoke() { StoreInformationSettings storeInformationSettings = _settingService.LoadSetting <StoreInformationSettings>(); SocialModel model = new SocialModel { FacebookLink = storeInformationSettings.FacebookLink, GooglePlusLink = storeInformationSettings.GooglePlusLink, TwitterLink = storeInformationSettings.TwitterLink, YoutubeLink = storeInformationSettings.YoutubeLink, Instagram = storeInformationSettings.InstagramLink }; return(View(model)); }
public ActionResult Index(string searchName) { SocialModel socialModel = null; try { socialModel = new SocialModel(); var restuls = _socialMediaConnector.GetSocialInfomation(searchName); socialModel.SocialMediaItems = restuls; } catch (Exception ex) { Logger.Error(ex); } return(View(socialModel)); }
private async Task <SocialModel> GetGoogleData() { SocialModel model = new SocialModel(); var account = AccountStore.Create().FindAccountsForService(AccountServiceGoogle).FirstOrDefault(); var request = new OAuth2Request("GET", new Uri("https://www.googleapis.com/oauth2/v2/userinfo"), null, account); var response = await request.GetResponseAsync(); if (response != null) { var userJson = JsonConvert.DeserializeObject <Dictionary <string, string> >(response.GetResponseText()); model.Id = userJson["id"]; model.Email = userJson["email"]; model.Name = userJson["name"]; model.AvatarUrl = userJson["picture"]; model.AuthType = AuthType.Google; } return(model); }
private SocialModel GetFBData(JObject fbUser) { SocialModel fbModel = new SocialModel(); fbModel.Name = fbUser["first_name"].ToString().Replace("\"", ""); fbModel.Id = fbUser["id"].ToString().Replace("\"", ""); fbModel.Email = fbUser["email"].ToString().Replace("\"", ""); var avatarUrl = ""; try { fbModel.AvatarUrl = fbUser["picture"]["data"]["url"].ToString(); Helpers.Settings.Current.AvatarUrl = avatarUrl; //Settings.Current.Avatar = await CurrentApp.Current.MainViewModel.ServiceApi.GetAvatar(Settings.Current.AvatarUrl); } catch (Exception) { } return(fbModel); }
public ActionResult RateShow(SocialModel socialService) { var rating = new RateModel(); var options = new NameValueCollection(); if (!string.IsNullOrEmpty(socialService.Url)) { rating.Url = socialService.Url; options.Add("ContentUrl", socialService.Url); } else { rating.ContentId = socialService.ContentId; rating.ContentTypeId = socialService.ContentTypeId; options.Add("ContentId", socialService.ContentId); } rating.Results = Get(Endpoints.RatingJson, options); return(PartialView("_rateService", rating)); }
public ActionResult Contacts() { //model var model = new SocialModel { FacebookLink = _storeInformationSettings.FacebookLink, TwitterLink = _storeInformationSettings.TwitterLink, YoutubeLink = _storeInformationSettings.YoutubeLink, GooglePlusLink = _storeInformationSettings.GooglePlusLink, InstagramLink = _storeInformationSettings.InstagramLink, VkLink = _storeInformationSettings.VkLink, Phone1 = _storeInformationSettings.Phone1, Phone2 = _storeInformationSettings.Phone2, Address = _storeInformationSettings.Address, Skype = _storeInformationSettings.Skype, Email = _storeInformationSettings.Email, WorkingLanguageId = _workContext.WorkingLanguage.Id, NewsEnabled = _newsSettings.Enabled, }; return(PartialView(model)); }
private ActionResult LikeGet(SocialModel socialService, string endpoint, bool checkIsLiked = false) { var like = new LikeModel(); var options = new NameValueCollection(); if (!string.IsNullOrEmpty(socialService.Url)) { like.Url = socialService.Url; options.Add("ContentUrl", socialService.Url); } else { like.ContentId = socialService.ContentId; like.ContentTypeId = socialService.ContentTypeId; options.Add("ContentId", socialService.ContentId); } if (checkIsLiked) { var optionsChecker = new NameValueCollection(options); var host = Host.Get("default"); var user = host.GetCurrentHttpContext().Items["SDK-User"] as User; if (user != null) { optionsChecker.Add("UserId", user.UserId.ToString(CultureInfo.InvariantCulture)); optionsChecker.Add("PageSize", "1"); optionsChecker.Add("PageIndex", "0"); } var likeChecker = Get(endpoint, optionsChecker); like.IsLiked = likeChecker != null && likeChecker.TotalCount > 0; } like.Results = Get(endpoint, options); return(PartialView("_likeService", like)); }
public bool SignInSocial(SocialModel model) { return true; }
public ActionResult LikeShow(SocialModel socialService) { return(LikeGet(socialService, Endpoints.LikeJson)); }
public ActionResult LikeList(SocialModel socialService) { return(LikeGet(socialService, Endpoints.LikesJson, true)); }
public bool SignInSocial(SocialModel model) { return(true); }
public ActionResult <SocialLinkModel> GetLinkParameters([FromHeader] int App_id, [FromBody] SocialModel socialModel) { if (string.IsNullOrEmpty(socialModel.Device)) { return(BadRequest("Field 'device' shouldn't be empty")); } Setting setting = context.Settings .FirstOrDefault(x => x.AppId == App_id && x.SocialId == socialModel.SocialId && x.IsActive); if (setting == null) { return(BadRequest("User settings are missing or social is disabled")); } Social social = context.Socials.FirstOrDefault(x => x.Id == setting.SocialId); if (social == null) { return(BadRequest("Can't find social")); } string socialName = context.Socials.FirstOrDefault(x => x.Id == socialModel.SocialId).Name.ToLower(); string redirectUri = $"https://{Request.Host}/auth/{socialName}"; var sessionId = Guid.NewGuid().ToString(); cache.Set(sessionId, new CacheModel { SocialId = socialModel.SocialId, Device = socialModel.Device, AppId = App_id, RedirectUri = redirectUri }, new MemoryCacheEntryOptions { AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(3) }); return(new SocialLinkModel { AuthUri = social.AuthUri, RedirectUri = redirectUri, ResponseType = "code", ClientId = setting.ClientId, Scope = setting.Scope, State = sessionId }); }