public override async Task <SenderLandPageConfiguration> Register(SignUpSender signUpSender) { var senderLandPageConfiguration = new SenderLandPageConfiguration(this.Provider.ServiceName) { Logo = "", MessageEmailTemplate = "Telegram", TextLandPageTemplate = "Telegram", TwoFactorAuthentication = true }; senderLandPageConfiguration.AddExtraFields(new FieldView { Name = "API_ID", Title = "API_ID" }) .AddExtraFields(new FieldView { Name = "API_HASH", Title = "API_HASH" }) .AddExtraFields(new FieldView { Name = "phone", Title = "phone" }); senderLandPageConfiguration.AddAcceptable("Remember It's will replace your whatsApp Application Account on your mobile phone!!!").AddHelpFile("/plugin/h.html"); var config = await Context.GetConfiguration <ConfigTelegram>(this.Provider.ServiceName, signUpSender.UserName); if (config != null && !String.IsNullOrEmpty(config.Token)) { senderLandPageConfiguration.IsAlreadyRegister = true; } return(senderLandPageConfiguration); }
public override async Task <SenderLandPageConfiguration> Register(SignUpSender signUpSender) { var senderLandPageConfiguration = new SenderLandPageConfiguration(this.Provider.ServiceName) { Logo = "/Resources/com.baladorPlant/WhatsApp/whatsapp64x64.png", MessageEmailTemplate = "WhatsApp", TextLandPageTemplate = "WhatsApp", TwoFactorAuthentication = true }; senderLandPageConfiguration .AddExtraFields(new FieldView { Name = "phone", Title = "phone" }) .AddExtraFields(new FieldView { Name = "method", Title = "method sms" }) .AddAcceptable("Remember It's will replace your whatsApp Application Account on your mobile phone!!!") .AddHelpFile("/Resources/com.baladorPlant/WhatsApp/helpfile.html"); var config = await Context.GetConfiguration <ConfigWhatsApp>(this.Provider.ServiceName, signUpSender.UserId); if (config != null && !String.IsNullOrEmpty(config.Token)) { senderLandPageConfiguration.IsAlreadyRegister = true; } return(senderLandPageConfiguration); }
public override async Task <SenderLandPageConfiguration> Register(SignUpSender signUpSender) { var senderLandPageConfiguration = new SenderLandPageConfiguration(this.Provider.ServiceName) { Logo = "/Resources/com.baladorPlant/MockHttpSender/whatsapp64x64.png", MessageEmailTemplate = "http test", TextLandPageTemplate = "http test", TwoFactorAuthentication = true }; senderLandPageConfiguration.ExtraFields.Add(new FieldView { Name = "pws", Title = "write password" }); senderLandPageConfiguration.ExtraFields.Add(new FieldView { Name = "client_id", Title = "client" }); senderLandPageConfiguration.ExtraFields.Add(new FieldView { Name = "grant_type", Title = "grant type" }); senderLandPageConfiguration.AddAcceptable("Remember It your mobile phone!!!") .AddHelpFile("/Resources/com.baladorPlant/MockHttpSender/helpfile.html"); var config = await Context.GetConfiguration <ConfigHttp>(this.Provider.ServiceName, signUpSender.UserId); if (config != null && !String.IsNullOrEmpty(config.Token)) { senderLandPageConfiguration.IsAlreadyRegister = true; } return(senderLandPageConfiguration); }
public override async Task <SenderLandPageConfiguration> Register(SignUpSender signUpSender) { var senderLandPageConfiguration = new SenderLandPageConfiguration(this.Provider.ServiceName) { Logo = "/Resources/com.baladorPlant/MockSender/telegram-logo64x64.png", MessageEmailTemplate = "http lite", TextLandPageTemplate = "http lite", TwoFactorAuthentication = false }; senderLandPageConfiguration.AddExtraFields(new FieldView { Name = "token", Title = "write token only " }); senderLandPageConfiguration.AddAcceptable("Remember It's will replace your whatsApp Application Account on your mobile phone!!!") .AddHelpFile("/Resources/com.baladorPlant/MockSender/helpfile.html"); var token = await GetToken(signUpSender); if (token != null) { senderLandPageConfiguration.IsAlreadyRegister = true; } return(senderLandPageConfiguration); }
public override async Task <ResponseBase> SetObservableToken(SignUpSender signUpSender, BToken token) { var config = await Context.GetConfiguration <ConfigHttp>(this.Provider.ServiceName, signUpSender.UserId); config.Token = token.Token; var result = await this.Context.SetConfiguration(this.Provider.ServiceName, signUpSender.UserId, config); return(result); }
public override async Task <BToken> GetToken(SignUpSender signUpSender) { ConfigWhatsApp config = await Context.GetConfiguration <ConfigWhatsApp>(Provider.ServiceName, signUpSender.UserId); if (config != null && !String.IsNullOrEmpty(config.Token)) { return(config); } return(null); }
public async Task <HttpResponseMessage> GetMessagers() { List <FormSignThirdPartyToken> authentications = new List <FormSignThirdPartyToken>(); try { SignUpSender signUpSender = await GetUserid(); Michal.Balador.Contracts.Mechanism.AuthenticationManager authenticationManager = null; MockRepository mockData = new MockRepository(); foreach (var senderRule in _senderRules) { authenticationManager = null; var factory = senderRule.Value; authenticationManager = factory.GetAuthenticationManager(); if (authenticationManager != null) { var configuration = await authenticationManager.Register(signUpSender); authentications.Add(new FormSignThirdPartyToken { Id = configuration.Id.ToString(), Fields = configuration.ExtraFields, Message = configuration.TextLandPageTemplate, Name = authenticationManager.AuthenticationName, Title = authenticationManager.AuthenticationTitle, IsAlreadyRegister = configuration.IsAlreadyRegister, TwoFactorAuthentication = configuration.TwoFactorAuthentication, Agreement = configuration.Agreement, HelpFile = configuration.HelpFile, IsAgreement = configuration.IsAgreement, Logo = configuration.Logo }); } } var response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new ObjectContent <FormSignThirdPartyToken[]>(authentications.ToArray(), new JsonMediaTypeFormatter(), new MediaTypeWithQualityHeaderValue("application/json")) }; return(response); } catch (Exception ee) { Console.WriteLine(ee); var response = new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new ObjectContent <FormSignThirdPartyToken[]>(authentications.ToArray(), new JsonMediaTypeFormatter(), new MediaTypeWithQualityHeaderValue("application/json")) }; return(response); } }
public override async Task <ResponseBase> UnRegister(SignUpSender signUpSender) { ResponseBase response = new ResponseBase(); var config = await Context.GetConfiguration <ConfigHttpLite>(this.Provider.ServiceName, signUpSender.UserId); if (config != null && !String.IsNullOrEmpty(config.Token)) { await Context.SetConfiguration(this.Provider.ServiceName, signUpSender.UserId, new ConfigHttpLite()); } return(response); }
public override async Task <ResponseBase> SetObservableToken(SignUpSender signUpSender, BToken token) { ConfigTelegram configTelegram = await Context.GetConfiguration <ConfigTelegram>(Provider.ServiceName, signUpSender.UserName); var store = new BaladorSessionStore(this.Context, configTelegram, this.Provider, signUpSender); var client = new TelegramClient(configTelegram.Api, configTelegram.Api_Hash, store); var user = await client.MakeAuthAsync(configTelegram.Phone, configTelegram.CodeRequest, token.Token); configTelegram.Token = token.Token; var result = await this.Context.SetConfiguration(this.Provider.ServiceName, signUpSender.UserName, configTelegram); return(result); }
public override async Task <ResponseBase> UnRegister(SignUpSender signUpSender) { ResponseBase response = new ResponseBase(); response.Message = "unregister done"; var config = await Context.GetConfiguration <ConfigTelegram>(this.Provider.ServiceName, signUpSender.UserName); if (config != null && !String.IsNullOrEmpty(config.Token)) { await Context.SetConfiguration(this.Provider.ServiceName, signUpSender.UserName, new ConfigTelegram()); } return(response); }
public override async Task <ResponseBase> SetObservableToken(SignUpSender signUpSender, BToken token) { var config = await Context.GetConfiguration <ConfigWhatsApp>(this.Provider.ServiceName, signUpSender.UserId); config.Token = token.Token; var pws = WhatsAppApi.Register.WhatsRegisterV2.RegisterCode(config.Phone, config.Token); //config.TempPwsSms = config.Token; config.Token = pws;//curent var result = await this.Context.SetConfiguration(this.Provider.ServiceName, signUpSender.UserId, config); return(result); }
public override async Task <Response <AuthenticationUser> > SignIn(SignUpSender senderDetail, NameValueCollection extraDataForm) { var response = new Response <AuthenticationUser>(); response.Result = new AuthenticationUser { IsTwoFactorAuthentication = true, UserId = senderDetail.UserId }; response.IsError = true; var url = "http://localhost:8988/token"; var httpClient = new HttpClient(); httpClient.DefaultRequestHeaders .Accept .Add(new MediaTypeWithQualityHeaderValue("application/json")); var dict = new Dictionary <string, string>(); var pws = extraDataForm["pws"]; var grant_type = extraDataForm["grant_type"]; var client_id = extraDataForm["client_id"]; dict.Add("username", senderDetail.UserId); dict.Add("password", pws); dict.Add("client_id", client_id); dict.Add("grant_type", grant_type); var req = new HttpRequestMessage(HttpMethod.Post, url) { Content = new FormUrlEncodedContent(dict) }; var res = await httpClient.SendAsync(req); if (res.IsSuccessStatusCode) { response.IsError = false; var stringRes = await res.Content.ReadAsStringAsync(); dynamic d = JObject.Parse(stringRes); // Console.WriteLine(d.access_token); Context.GetLogger().Log(System.Diagnostics.TraceLevel.Verbose, stringRes); if (d != null) { await Context.SetConfiguration(this.Provider.ServiceName, senderDetail.UserId, new ConfigHttp { UserId = senderDetail.UserId, RefreshToken = d.refresh_token, Token = d.access_token }); } // } return(response); }
public override async Task <Response <AuthenticationUser> > SignIn(SignUpSender senderDetail, NameValueCollection extraDataForm) { var response = new Response <AuthenticationUser>(); response.Result = new AuthenticationUser { IsTwoFactorAuthentication = true, UserId = senderDetail.UserName }; response.IsError = true; var phone = extraDataForm["phone"]; var api = extraDataForm["API_ID"]; var apiHash = extraDataForm["API_HASH"]; int apiId = int.Parse(api); ConfigTelegram configTelegram = await Context.GetConfiguration <ConfigTelegram>(Provider.ServiceName, senderDetail.UserName); var store = new BaladorSessionStore(this.Context, configTelegram, this.Provider, senderDetail); var client = new TelegramClient(apiId, apiHash, store); var isconnected = await client.ConnectAsync(); if (!isconnected) { return(new Response <AuthenticationUser> { IsError = true, Message = "unable to connect" }); } configTelegram = configTelegram ?? new ConfigTelegram { Token = "", Phone = phone, Api = apiId, Api_Hash = apiHash }; var estaRegistrado = await client.IsPhoneRegisteredAsync(phone); if (estaRegistrado) { if (!client.IsUserAuthorized()) { configTelegram.CodeRequest = await client.SendCodeRequestAsync(phone); } } var isregister = await client.ConnectAsync(); if (isregister) { response.IsError = false; await Context.SetConfiguration(this.Provider.ServiceName, senderDetail.UserName, new ConfigTelegram { Token = "", Phone = phone }); } return(response); }
public override async Task <ResponseBase> SetObservableToken(SignUpSender signUpSender, BToken token) { var config = await Context.GetConfiguration <ConfigHttpLite>(this.Provider.ServiceName, signUpSender.UserId); if (config == null) { config = new ConfigHttpLite { Token = token.Token, UserId = signUpSender.UserId }; } else { config.Token = token.Token; } var result = await this.Context.SetConfiguration(this.Provider.ServiceName, signUpSender.UserId, config); return(result); }
public override async Task <Response <AuthenticationUser> > SignIn(SignUpSender senderDetail, NameValueCollection extraDataForm) { var response = new Response <AuthenticationUser>(); response.IsError = false; response.Result = new AuthenticationUser { IsTwoFactorAuthentication = false, UserId = senderDetail.UserId }; var url = "http://localhost:1945/token"; var httpClient = new HttpClient(); httpClient.DefaultRequestHeaders .Accept .Add(new MediaTypeWithQualityHeaderValue("application/json")); var dict = new Dictionary <string, string>(); var pws = extraDataForm["token"]; await Context.SetConfiguration(this.Provider.ServiceName, senderDetail.UserId, new ConfigHttpLite { Token = pws }); return(response); }
public async Task <HttpResponseMessage> SetToken(HttpRequestMessage request) { ResponseBase responseResult = new ResponseBase(); try { SignUpSender signUpSender = await GetUserid(); NameValueCollection formData = await request.Content.ReadAsFormDataAsync(); var id = formData[ConstVariable.FORM_TYPE]; var token = formData["token"]; foreach (var senderRule in _senderRules) { var factory = senderRule.Value; var authenticationManager = factory.GetAuthenticationManager(); if (authenticationManager.ServiceName == id) { responseResult = await authenticationManager.SetObservableToken(signUpSender, new BToken { Token = token }); break; } } } catch (Exception eee) { responseResult.IsError = true; responseResult.Message = eee.Message; //throw; } var response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new ObjectContent <ResponseBase>(responseResult, new JsonMediaTypeFormatter(), new MediaTypeWithQualityHeaderValue("application/json")) }; return(response); }
public override async Task <Response <AuthenticationUser> > SignIn(SignUpSender senderDetail, NameValueCollection extraDataForm) { var response = new Response <AuthenticationUser>(); response.Result = new AuthenticationUser { IsTwoFactorAuthentication = true, UserId = senderDetail.UserId }; response.IsError = true; var phone = extraDataForm["phone"]; var method = "sms";// extraDataForm["method"]; string password = ""; var isregister = WhatsAppApi.Register.WhatsRegisterV2.RequestCode(phone, out password, method); if (isregister) { response.IsError = false; await Context.SetConfiguration(this.Provider.ServiceName, senderDetail.UserId, new ConfigWhatsApp { Token = password, Phone = phone }); } return(response); }
public async Task <ResponseAppMessanger> SetSocketClient(SignUpSender sender, bool canExcute = true) { ResponseAppMessanger response = new ResponseAppMessanger(); response.Result = this; if (_test != null) { return(response); } var authenticationManager = GetAuthenticationManager(); var token = await authenticationManager.GetToken(sender); if (token == null) { response.IsAutorize = false; response.IsError = false; } else { response.IsAutorize = true; SenderMessagesFactory sendFactory = new SenderMessagesFactory(this.Context); var respndFactory = await sendFactory.ConnectAndLogin(sender.UserId, token.Token); if (respndFactory.IsError) { response.IsAutorize = true; response.IsError = true; response.Message = respndFactory.Message; } else { _test = respndFactory.Result; } } return(response); }
public BaladorSessionStore(IBaladorContext context, ConfigTelegram configTelegram, IAppMessangerFactrory provider, SignUpSender signUpSender) { _context = context; _configTelegram = configTelegram; _provider = provider; _signUpSender = signUpSender; }