mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-08-23 17:47:26 +00:00
Remove sync consent check, add error message to youtube edit page and check that email is changed
This commit is contained in:
parent
26f569f866
commit
fcafd053cb
6 changed files with 34 additions and 12 deletions
|
@ -67,7 +67,24 @@ class AcquisitionActions extends Actions
|
|||
Controller::redirect($token['data']);
|
||||
}
|
||||
}
|
||||
public static function actionYoutubeEdit($status_token, $channel_name, $email, $sync_consent, $current_value)
|
||||
{
|
||||
if($current_value['data']['email'] == $email)
|
||||
{
|
||||
$status = LBRY::editYoutube($status_token, $channel_name, null, $sync_consent);
|
||||
}
|
||||
else
|
||||
{
|
||||
$status = LBRY::editYoutube($status_token, $channel_name, $email, $sync_consent);
|
||||
}
|
||||
|
||||
if($status['success'] == false){
|
||||
Controller::redirect("/youtube/status/". $status_token . "?error=true&error_message=" . $status['error']);
|
||||
}
|
||||
else{
|
||||
Controller::redirect("/youtube/status/" . $status_token);
|
||||
}
|
||||
}
|
||||
public static function executeYoutubeEdit(){
|
||||
return ['acquisition/youtube_edit'];
|
||||
}
|
||||
|
|
10
lib/thirdparty/LBRY.class.php
vendored
10
lib/thirdparty/LBRY.class.php
vendored
|
@ -29,7 +29,7 @@ class LBRY
|
|||
{
|
||||
return Curl::post(static::getApiUrl('/list/unsubscribe'), ['email' => $email], ['json_response' => true]);
|
||||
}
|
||||
|
||||
|
||||
public static function connectYoutube($channel_name)
|
||||
{
|
||||
$type = 'sync';
|
||||
|
@ -49,6 +49,12 @@ class LBRY
|
|||
|
||||
public static function editYouTube($status_token, $channel_name, $email, $sync_consent)
|
||||
{
|
||||
return Curl::post(static::getApiUrl("/yt/update"), ['status_token' => $status_token, 'new_email' => $email, 'new_preferred_channel' => $channel_name, 'sync_consent' => $sync_consent], ['json_response' => true]);
|
||||
if ($email == null){
|
||||
return Curl::post(static::getApiUrl("/yt/update"),['status_token' => $status_token, 'new_preferred_channel' => $channel_name, 'sync_consent' => $sync_consent],['json_response' => true]);
|
||||
}
|
||||
else{
|
||||
|
||||
return Curl::post(static::getApiUrl("/yt/update"), ['status_token' => $status_token, 'new_email' => $email, 'new_preferred_channel' => $channel_name, 'sync_consent' => $sync_consent], ['json_response' => true]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,10 @@ $channel_name = $_POST['new_preferred_channel'];
|
|||
$email = $_POST['new_email'];
|
||||
$sync_consent = isset($_POST['sync_consent']);
|
||||
|
||||
LBRY::editYouTube($status_token, $channel_name, $email, $sync_consent);
|
||||
$current_value = LBRY::statusYoutube($status_token);
|
||||
|
||||
if(!preg_match("/([@][1-z]+)/", $channel_name)){
|
||||
$channel_name = "@" . $channel_name;
|
||||
}
|
||||
|
||||
Controller::redirect("/youtube/status/" . $status_token);
|
||||
AcquisitionActions::actionYoutubeEdit($status_token, $channel_name, $email, $sync_consent, $current_value);
|
||||
|
|
|
@ -33,6 +33,9 @@
|
|||
<div>
|
||||
<input type="hidden" name="status_token" id="status_token" value="<?php echo $token?>"/>
|
||||
</div>
|
||||
<?php
|
||||
if (isset($_GET['error'])): echo "<div>" . "The following error occurred: ". $_GET['error_message'] . " For support please send an email to hello@lbry.io" . "</div>";
|
||||
endif;?>
|
||||
<div class="block">
|
||||
<label for="channel-name">LBRY channel name:</label>
|
||||
<input type="text" id="channel-name" name="new_preferred_channel" placeholder="@YourPreferredChannelName" value="<?php echo $status['data']['lbry_channel_name'];?>">
|
||||
|
@ -44,7 +47,7 @@
|
|||
<div hidden id="email-error" class="error">Email is invalid or blank</div>
|
||||
</div>
|
||||
<div class="block full">
|
||||
<input name="sync_consent" id="sync-consent" type="checkbox">I want to sync my content to the LBRY network and agree to the "terms"
|
||||
<input name="sync_consent" id="sync-consent" type="checkbox" <?php if($status['data']['status'] == 'queued'): echo "checked"; endif;?> <?php if($status['data']['status'] == 'syncing' || $status['data']['status'] == 'synced'): echo "disabled "; echo "checked"; endif; ?>>I want to sync my content to the LBRY network and agree to the "terms"
|
||||
<div hidden id="sync-consent-error" class="error">You must agreed to sync to continue</div>
|
||||
</div>
|
||||
<div class="block">
|
||||
|
|
|
@ -5,4 +5,3 @@ if(!preg_match("/([@][1-z]+)/", $desired_lbry_channel_name)){
|
|||
$desired_lbry_channel_name = "@" . $desired_lbry_channel_name;
|
||||
}
|
||||
AcquisitionActions::actionYoutubeToken($desired_lbry_channel_name);
|
||||
?>
|
||||
|
|
|
@ -22,12 +22,6 @@ function submitEditForm(){
|
|||
event.preventDefault();
|
||||
}
|
||||
|
||||
// If the checkbox is not check stop the post request
|
||||
if(!$('#sync-consent').prop('checked')){
|
||||
$('#sync-consent').addClass('error_form');
|
||||
$('#sync-consent-error').show();
|
||||
event.preventDefault();
|
||||
}
|
||||
localStorage.setItem("status_token", $.trim($('#status_token').val()));
|
||||
localStorage.setItem("lbry_channel_name_sync", $.trim($('#channel-name').val()));
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue