Skip to content

Commit

Permalink
Cypht: Improve interface so user is warned about the need for App Pas…
Browse files Browse the repository at this point in the history
…sword for Gmail-IMAP
  • Loading branch information
jeanpaulHamuli committed Nov 29, 2021
1 parent 05d0af9 commit 04a0026
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 3 deletions.
10 changes: 10 additions & 0 deletions modules/core/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -600,3 +600,13 @@ function get_special_folders($mod, $id) {
}
return array();
}


if (!hm_exists('is_gmail_server')) {
function is_gmail_server($server, $text, $disabled) {
if($server == $text && !$disabled){
return '<div class="warning_message">Make sure your <a href="https://myaccount.google.com/lesssecureapps" target="_blank">Less secure app access</a> and your App password are enabled. For more details about the configuration of IMAP, POP and SMTP click <a href="https://developers.google.com/gmail/imap/imap-smtp" target="_blank">here</a></div>';
}else{
return '';
}
}}
2 changes: 2 additions & 0 deletions modules/core/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,5 @@ div.unseen, .unseen .subject { font-weight: 700; }
@media print {
.sys_messages, .next, .prev, .folder_list, .msg_parts, .header_links, .content_title, .add_contact_row, .unsaved_icon, .add_vcal { display: none !important; }
}

div.warning_message { margin-bottom: 20px !important; }
2 changes: 1 addition & 1 deletion modules/imap/output_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ protected function output() {
$res .= '<form class="imap_connect" method="POST">'.
'<input type="hidden" name="hm_page_key" value="'.$this->html_safe(Hm_Request_Key::generate()).'" />'.
'<input type="hidden" name="imap_server_id" class="imap_server_id" value="'.$this->html_safe($index).'" /><span> '.
'<label class="screen_reader" for="imap_user_'.$index.'">'.$this->trans('IMAP username').'</label>'.
'<label class="screen_reader" for="imap_user_'.$index.'">'.$this->trans('IMAP username').'</label>'.is_gmail_server($this->html_safe($vals['server']), 'imap.gmail.com', $disabled).
'<input '.$disabled.' id="imap_user_'.$index.'" class="credentials" placeholder="'.$this->trans('Username').
'" type="text" name="imap_user" value="'.$this->html_safe($user_pc).'"></span>'.
'<span><label class="screen_reader" for="imap_pass_'.$index.'">'.$this->trans('IMAP password').'</label>'.
Expand Down
2 changes: 1 addition & 1 deletion modules/imap/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@
#archive_val { padding-left: 20px; }

.attached_image { margin-right: 20px; margin-bottom: 20px; height: 200px; }
.attached_image_box { display: flex; flex-wrap: wrap; border-top: solid 1px #ddd; padding-top: 20px; padding-left: 20px; width: 100%; padding-bottom: 40px; }
.attached_image_box { display: flex; flex-wrap: wrap; border-top: solid 1px #ddd; padding-top: 20px; padding-left: 20px; width: 100%; padding-bottom: 40px; }
1 change: 1 addition & 0 deletions modules/nux/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ function credentials_form($details, $mod) {
$res .= '<input type="hidden" name="nux_name" class="nux_name" value="'.$mod->html_safe($details['name']).'" />';
$res .= '<div class="nux_step_two_title">'.$mod->html_safe($details['name']).'</div>';
$res .= $mod->trans('Enter your password for this E-mail provider to complete the connection process');
$res .= $details['id'] === 'gmail' ? $mod->trans(', but before make sure your ').'<a href="https://myaccount.google.com/lesssecureapps?pli=1&rapt=AEjHL4NpkmwIETHerv6E5u7cJwKhX3JflUzEUBvt0z55QIYxmY1vHhRoUkAucfLyPP5WvH9qQQwPHeZfeZ4y7mvrYN7R_OVnQA" target="_blank">'.$mod->trans('Less secure app access ').'</a>' .$mod->trans(' and your App Password for your gmail account are on. For more details about the configuration of IMAP, POP and SMTP click ').'<a href="https://developers.google.com/gmail/imap/imap-smtp" target="_blank">'.$mod->trans('here').'</a>' : '';
$res .= '<br /><br /><label class="screen_reader" for="nux_email">';
$res .= $mod->trans('E-mail Address').'</label><input type="email" id="nux_email" name="nux_email" value="'.$mod->html_safe($details['email']).'" />';
$res .= '<br /><label class="screen_reader" for="nux_password">'.$mod->trans('E-mail Password').'</label>';
Expand Down
2 changes: 1 addition & 1 deletion modules/smtp/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ protected function output() {
'<form class="smtp_connect" method="POST">'.
'<input type="hidden" name="hm_page_key" value="'.$this->html_safe(Hm_Request_Key::generate()).'" />'.
'<input type="hidden" name="smtp_server_id" value="'.$this->html_safe($index).'" /><span> '.
'<label class="screen_reader" for="smtp_user_'.$index.'">'.$this->trans('SMTP username').'</label>'.
'<label class="screen_reader" for="smtp_user_'.$index.'">'.$this->trans('SMTP username').'</label>'.is_gmail_server($this->html_safe($vals['server']), 'smtp.gmail.com', $disabled).
'<input '.$disabled.' class="credentials" id="smtp_user_'.$index.'" placeholder="'.$this->trans('Username').
'" type="text" name="smtp_user" value="'.$this->html_safe($user_pc).'"></span><span> <label class="screen_reader" for="smtp_pass_'.
$index.'">'.$this->trans('SMTP password').'</label><input '.$disabled.' class="credentials smtp_password" placeholder="'.
Expand Down

0 comments on commit 04a0026

Please sign in to comment.