Guest User

Untitled

a guest
Jul 30th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. Drupal 7 Bridge
  2. function my_module_authentication_menu_hook() {
  3. // Note anywhere below that I put return FALSE you should return a failed auth response.
  4. // Where there is a return TRUE you should return a successful auth response.
  5. // The formatting of the auth response is up to you with how your Moodle call will react.
  6. if (!isset($_POST['username']) || !isset($_POST['password'])) {
  7. return FALSE;
  8. }
  9.  
  10. $username = $_POST['username'];
  11. $password = $_POST['password'];
  12.  
  13. // Functionality from user_login_name_validate().
  14. if (user_is_blocked($username)) {
  15. return FALSE;
  16. }
  17.  
  18. // Functionality from user_login_authenticate_validate().
  19. // You should add flood handling in here as well, but it can not be IP based, unless you
  20. // supply the IP of the user through your Moodle functionality.
  21. if (user_authenticate($username, $password) === FALSE) {
  22. return FALSE;
  23. }
  24.  
  25. // See user_login_final_validate() and implement failed login functionality before success.
  26. return TRUE;
  27. }
Add Comment
Please, Sign In to add comment