Author Topic: Update profile on first login.  (Read 7366 times)

Offline NetLink

  • Newbie
  • *
  • Posts: 4
Update profile on first login.
« on: October 11, 2007, 12:01:19 AM »
Hello! Some mail servers use a FQDN such as "a-123-bc.example.com". Also, it is often common that users have usernames that are different from their actual e-mail address, which they use to authenticate themselves to the mail server - for example "web78".

When a user on such a mail server uses RoundCube (which by the way is very nice!) without having set up their profile, any mail sent from them will contain an address such as "web78@a-123-bc.example.com" in the From header. To prevent this from happening, it would be great if RoundCube requests the user to update his/her profile after the first login. RoundCube uses a MySQL database, so this would definitely be possible. Could this be implemented?

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,882
    • SKaero - Custom Roundcube development
Re: Update profile on first login.
« Reply #1 on: October 11, 2007, 05:55:22 AM »
It could be done but it would make a db lager then it is already, and would be a god bit of code So may be on a later version or a plug-in.

Offline NetLink

  • Newbie
  • *
  • Posts: 4
Re: Update profile on first login.
« Reply #2 on: October 12, 2007, 12:11:46 AM »
Quote from: SKaero
It could be done but it would make a db lager then it is already, and would be a god bit of code So may be on a later version or a plug-in.

I don't think you would need to add any tables or fields to the database. You could add something like this to the ./index.php file :

Code: [Select]
// log in to imap server
if (!empty($_SESSION['user_id']) && $_task=='mail')
 {
 $DB->query("SELECT * FROM " . get_table_name('identities') . " WHERE user_id='" . $_SESSION['user_id'] ."'");
 // $rows = [ Get number of records returned ];
 if ( $rows < 1 ) {
  $_task = 'settings';
  $_action = 'add-identity';
 } else {
  $conn = $IMAP->connect($_SESSION['imap_host'], $_SESSION['username'], decrypt_passwd($_SESSION['password']), $_SESSION['imap_port'], $_SESSION['imap_ssl']);
  if (!$conn)
   {
   show_message('imaperror', 'error');
   $_SESSION['user_id'] = '';
   }
  else
   rcmail_set_imap_prop();
  }
 }


I could be wrong as I haven't really studied the code, but from what I can tell, it would just be a matter of adding those lines. I would implement this in my own installation, but unfortunately I have not been able to figure out yet how to get the number of records returned from the DB query :) Help on that would be appreciated (if it's just a matter of calling a function from the DB class, etc.) ...

Offline NetLink

  • Newbie
  • *
  • Posts: 4
Re: Update profile on first login.
« Reply #3 on: October 12, 2007, 01:56:14 AM »
Ok, I saw that things were a little more complicated. I realised that a identity is automatically added after first login. I've now used a "quick and dirty" method to force users to check their identities. Am setting a session after the user has entered the identities screen, and I use the following to redirect the user if the session has not been set (./index.php):

Code: [Select]
// log in to imap server
if (!empty($_SESSION['user_id']) && $_task=='mail') {
$id_updated = isset($_SESSION['id_updated']) ? $_SESSION['id_updated'] : 0;
if ( empty($id_updated) ) {
header( &quot;Location: ./?_task=settings&_action=identities&quot; );
exit;
} else {
$conn = $IMAP->connect($_SESSION['imap_host'], $_SESSION['username'], decrypt_passwd($_SESSION['password']), $_SESSION['imap_port'], $_SESSION['imap_ssl']);
if (!$conn) {
show_message('imaperror', 'error');
$_SESSION['user_id'] = '';
} else {
rcmail_set_imap_prop();
}
}
}

Offline vanbroup

  • Newbie
  • *
  • Posts: 9
Re: Update profile on first login.
« Reply #4 on: October 30, 2007, 05:50:44 AM »
I there can be set a flag 0/1 in the identities table to see if the user has already checked his identity, now you can also force a user to recheck his identity by setting the flag back to zero.

I think this solution should be really simple to implement and does not require a lot of database space.

The identity information is really important, with our current webmail software we get a lot of complains about this!