You are here

function _cas_server_save_ticket in CAS 7

Same name and namespace in other branches
  1. 5.4 cas_server.module \_cas_server_save_ticket()
  2. 5.3 cas_server.module \_cas_server_save_ticket()
  3. 6.3 cas_server.module \_cas_server_save_ticket()
  4. 6.2 cas_server.module \_cas_server_save_ticket()

Generate a one time use login ticket for the user in question.

Parameters

int $uid:

1 call to _cas_server_save_ticket()
cas_server_service_return in ./cas_server.module

File

./cas_server.module, line 300
Provides a protocol compliant version of CAS server 2.x

Code

function _cas_server_save_ticket($uid, $service) {

  // Generate the ticket
  $time = REQUEST_TIME;
  $ticket = 'ST-' . user_password();
  $ticket_data = array(
    'uid' => $uid,
    'service' => $service,
    'ticket' => $ticket,
    'timestamp' => $time,
    'valid' => 1,
  );

  // Save the ticket to the db
  if ($uid && $service) {
    db_insert('cas_server_tickets')
      ->fields($ticket_data)
      ->execute();
  }
  return $ticket;
}