Finishes advanced search on addresses to our new geocoding engine (gmaps v3).
[platal.git] / classes / xnetsession.php
index ceaa331..27ed4d8 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2010 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -34,6 +34,26 @@ class XnetSession extends XorgSession
             }
         }
 
+        if (!S::logged() && Post::has('auth_type') && Post::v('auth_type') == 'xnet' && !Post::has('wait')) {
+            $email = Post::v('username');
+            $type = XDB::fetchOneCell('SELECT  type
+                                         FROM  accounts
+                                        WHERE  email = {?}',
+                                      $email);
+            if ((!is_null($type) && $type != 'xnet') || !User::isForeignEmailAddress($email)) {
+                Platal::page()->trigErrorRedirect('Ce formulaire d\'authentification est réservé aux extérieurs à la communauté polytechnicienne.', '');
+            }
+
+            $user = parent::doAuth(AUTH_MDP);
+            if (is_null($user)) {
+                return false;
+            }
+            if (!parent::checkAuth(AUTH_MDP) || !parent::startSessionAs($user, AUTH_MDP)) {
+                $this->destroy();
+                return false;
+            }
+        }
+
         global $globals;
         if (!S::logged() && $globals->xnet->auth_baseurl) {
             // prevent connection to be linked to disconnection