当前位置: 首页>>代码示例>>PHP>>正文


PHP User::findByEmail方法代码示例

本文整理汇总了PHP中User::findByEmail方法的典型用法代码示例。如果您正苦于以下问题:PHP User::findByEmail方法的具体用法?PHP User::findByEmail怎么用?PHP User::findByEmail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在User的用法示例。


在下文中一共展示了User::findByEmail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create

 /**
  * Attempt to create a user, given a user email and a password
  */
 function create($email, $password, $idSession)
 {
     $user = new User();
     $userRow = $user->findByEmail($email);
     $config = new Config();
     $configRow = $config->fetchAll()->current();
     // Does this user exist?
     if ($userRow) {
         // Check the password
         if ($userRow->password == md5($password)) {
             // Delete a possibly existing session. Safer.
             $db = Zend_Db_Table::getDefaultAdapter();
             $db->query("DELETE FROM Session WHERE idSession = '{$idSession}'");
             // Insert in Session, for 2 hours
             $sessionRow = $this->createRow();
             $sessionRow->idSession = $idSession;
             $sessionRow->id_user = $userRow->id;
             $this->tempsLimite = date("U") + 7200;
             $sessionRow->roles = $userRow->roles;
             $sessionRow->save();
             return true;
         }
         return false;
     } else {
         return false;
     }
 }
开发者ID:camilorivera,项目名称:INNOVARE,代码行数:30,代码来源:Session.php

示例2: getUser

 public function getUser()
 {
     if ($this->_user === false) {
         $this->_user = User::findByEmail($this->email);
     }
     return $this->_user;
 }
开发者ID:brygom,项目名称:yii2-advanced-template-rbac,代码行数:7,代码来源:LoginForm.php

示例3: routeShutdown

 public function routeShutdown(Zend_Controller_Request_Abstract $request)
 {
     $logger = Zend_Registry::get('logger');
     $auth = Zend_Auth::getInstance();
     $logger->debug('Login -- hasIdentity ' . var_export($auth->hasIdentity(), true) . '. module: ' . $request->getModuleName() . '. _onAllowLogOutAccess: ' . var_export($this->_onAllowLogOutAccess($request), true));
     if (!$auth->hasIdentity() && $request->getModuleName() !== 'Auth' && !$this->_onAllowLogOutAccess($request)) {
         $request->setModuleName("Auth")->setControllerName("index")->setActionName("login");
     } elseif ($auth->hasIdentity()) {
         $session = DZend_Session_Namespace::get('session');
         if (!isset($session->user)) {
             $userModel = new User();
             $session->user = $userModel->findByEmail($auth->getIdentity());
         }
         DZend_Session_Namespace::close();
     }
 }
开发者ID:dmelo,项目名称:dzend,代码行数:16,代码来源:Login.php

示例4: Exception

             throw new Exception("Invalid ID message");
         }
         $message->setUnread(true, Session::getSessionEmail())->doUpdate();
     } catch (Exception $e) {
         $errors["unread"] = $e->getMessage();
     }
 } else {
     if (isset($_POST["sent"])) {
         $form = "sent";
         $to = Tools::prepareUserArgString($_POST["email"]);
         $subject = Tools::prepareUserArgString($_POST["subject"]);
         $texte = Tools::prepareUserArgString($_POST["message"]);
         if (!Tools::verifyEmail($to)) {
             $errors["email"] = "Invalid email format";
         } else {
             if (User::findByEmail($to) == null) {
                 $errors["email"] = "Unknow email address";
             } else {
                 try {
                     $message = Message::create($subject, $texte, Session::getSessionEmail(), $to);
                 } catch (Exception $e) {
                     $errors["other"] = $e->getMessage();
                 }
             }
         }
     } else {
         if (isset($get)) {
             if (Tools::isStringValid($get) && isGetType($type)) {
                 $type = $get;
                 if (!isNew($type)) {
                     $id = Tools::prepareUserArgInteger($_GET["id"]);
开发者ID:xxxkikixxx,项目名称:sti_projet_2,代码行数:31,代码来源:message.php

示例5: session_start

<?php

session_start();
try {
    // Get email address from request body
    $email = filter_input(INPUT_POST, 'email');
    // Get password from request body
    $password = filter_input(INPUT_POST, 'password');
    // Find account with email address (THIS IS PSUEDO-CODE)
    $user = User::findByEmail($email);
    // Verify password with account password hash
    if (password_verify($password, $user->password_hash) === false) {
        throw new Exception('Invalid password');
    }
    // Re-hash password if necessary (see note below)
    $currentHashAlgorithm = PASSWORD_DEFAULT;
    $currentHashOptions = array('cost' => 15);
    $passwordNeedsRehash = password_needs_rehash($user->password_hash, $currentHashAlgorithm, $currentHashOptions);
    if ($passwordNeedsRehash === true) {
        // Save new password hash (THIS IS PSUEDO-CODE)
        $user->password_hash = password_hash($password, $currentHashAlgorithm, $currentHashOptions);
        $user->save();
    }
    // Save login status to session
    $_SESSION['user_logged_in'] = 'yes';
    $_SESSION['user_email'] = $email;
    // Redirect to profile page
    header('HTTP/1.1 302 Redirect');
    header('Location: /user-profile.php');
} catch (Exception $e) {
    header('HTTP/1.1 401 Unauthorized');
开发者ID:skylei,项目名称:modern-php,代码行数:31,代码来源:login.php

示例6: array

<?php

include_once 'includes/config.php';
/*
 * Traitement du formulaire.
 */
if (Session::isAlreadyConnected()) {
    $usr = User::findByEmail(Session::getSessionEmail());
    if ($usr == null) {
        $errors["other"] = "Impossible to load your data.";
    } else {
        if (isset($_POST["changepwd"])) {
            $errors = array();
            $formValid = true;
            $old = Tools::prepareUserArgString($_POST["old"]);
            $new = Tools::prepareUserArgString($_POST["new"]);
            $new2 = Tools::prepareUserArgString($_POST["new2"]);
            if (!$usr->isPasswordCorrect($old)) {
                $formValid = false;
                $errors["old"] = "The old password is not correct.";
            }
            if (!Tools::verifyPassword($new)) {
                $formValid = false;
                $errors["new"] = "You must insert a valid password see password <a href=\"#\">hint</a>.";
            }
            // Si non-identique.
            if ($new !== $new2) {
                $formValid = false;
                $errors["new2"] = "You must insert the same password twice.";
            }
            if ($formValid) {
开发者ID:xxxkikixxx,项目名称:sti_projet_2,代码行数:31,代码来源:profil.php

示例7: create

 /**
  *
  * @param string $email        	
  * @param string $password        	
  * @param string $right        	
  * @param boolean $actif        	
  */
 public static function create($email, $password, $right, $actif)
 {
     // Vérifie que les champs soit du bon format.
     if (!Tools::isStringValid($email) || !Tools::isStringValid($password) || !Tools::isStringValid($right) || !Tools::isBooleanValid($actif)) {
         throw new Exception("Invalid user arguments type.");
     }
     // Vérifie s'il s'agit d'un email.
     if (!Tools::verifyEmail($email)) {
         throw new Exception("Invalid email format.");
     }
     // Vérifie que l'utilisateur n'existe pas déjà.
     if (User::findByEmail($email) != null) {
         throw new Exception("Invalid email, user already exist.");
     }
     // Crée un nouvel utilisateur.
     $user = new User();
     // Récupère le droit utilisateur.
     $user->right = Right::findByName($right);
     if ($user->right == null) {
         throw new Exception("Invalid right.");
     }
     // Set les autres paramètres
     $user->id = null;
     $user->email = $email;
     $user->photo = "";
     $user->salt = Tools::randomSalt();
     $user->password = Tools::doHash($password, $user->salt);
     $user->actif = $actif;
     try {
         // Effectue une connexion à la DB.
         $pdo = DBconnect();
         // Commence la transaction.
         $pdo->beginTransaction();
         // Prépare la requête.
         $stmt = $pdo->prepare("INSERT INTO t_user(email, password, salt, actif, fk_right) VALUES (:email, :password, :salt, :actif, :fk_right)");
         $stmt->bindParam(":email", $user->email);
         $stmt->bindParam(":password", $user->password);
         $stmt->bindParam(":salt", $user->salt);
         $stmt->bindParam(":actif", $user->actif);
         $stmt->bindParam(":fk_right", $user->right->getId());
         if ($stmt->execute()) {
             $pdo->commit();
         } else {
             throw new Exception();
         }
     } catch (Exception $e) {
         // Revient en arrière si une erreur c'est produite.
         $pdo->rollBack();
         // Envoie à nouveau une exception.
         throw new Exception("Create user aborted , an error occurated.");
     } finally {
         // Ferme le traitement.
         $stmt->closeCursor();
         // Ferme la connexion vers la base de donnée.
         $pdo = null;
     }
 }
开发者ID:xxxkikixxx,项目名称:sti_projet_2,代码行数:64,代码来源:fctusers.php

示例8: sendPasswordReset

    /**
     * Send the user password reset email
     *
     * @param string $email  Email address
     * @return void
     */
    public function sendPasswordReset($email)
    {
        $user = User::findByEmail($email);
        if ($user !== null) {
            if ($user->startPasswordReset()) {
                // Note hardcoded protocol
                $url = 'http://' . $_SERVER['HTTP_HOST'] . '/reset_password.php?token=' . $user->password_reset_token;
                $body = <<<EOT

<p>Please click on the following link to reset your password.</p>

<p><a href="{$url}">{$url}</a></p>

EOT;
                Mail::send($user->name, $user->email, 'Password reset', $body);
            }
        }
    }
开发者ID:sunitha181288,项目名称:Signup-and-Login-From-Scratch-Using-PHP,代码行数:24,代码来源:Auth.class.php

示例9: json_decode

    $request = json_decode($postdata);
    error_log("The request is: ");
    error_log(print_r($request, true));
    error_log("The request token is: {$request->token}");
    error_log("The request email is: {$request->email}");
    if (!isset($request->token)) {
        echo json_encode(array('status' => 'error', 'error' => 'couldn\'t get the token from post request'));
        exit;
    }
    if (!isset($request->email)) {
        echo json_encode(array('status' => 'error', 'error' => 'couldn\'t get the user\'s email from post request'));
        exit;
    }
    // First, find the user_id of the person who just logged in
    $userEmail = $request->email;
    $loggedInUser = User::findByEmail($userEmail);
    error_log("The user found by the email is: ");
    error_log(print_r($loggedInUser, true));
    $curUserId = $loggedInUser->id;
    error_log("The user id is: {$curUserId}");
    $userDeviceToken = $request->token;
    error_log("The user's device token is {$userDeviceToken}");
    $success = User::updateUserDeviceToken($curUserId, $userDeviceToken);
    if ($success) {
        Log::user("Successfully updated user device token");
        echo json_encode(array('status' => 'success', 'userDeviceToken' => $userDeviceToken));
    } else {
        Log::user("Error in updating user device token");
        echo json_encode(array('status' => 'failure'));
    }
} else {
开发者ID:bklam,项目名称:1eq_sample,代码行数:31,代码来源:pushNotifications.php

示例10: create

 /**
  *
  * @param string $subject        	
  * @param string $texte        	
  * @param string $sender        	
  * @param string $receiver        	
  */
 public static function create($subject, $texte, $sender, $receiver)
 {
     // Vérifie que les champs soit du bon format.
     if (!Tools::isStringValid($subject) || !Tools::isStringValid($texte) || !Tools::isStringValid($sender) || !Tools::isStringValid($receiver)) {
         throw new Exception("Invalid user arguments type.");
     }
     // Vérifie s'il s'agit d'un email.
     if (!Tools::verifyEmail($sender)) {
         throw new Exception("Invalid sender email format.");
     }
     // Vérifie s'il s'agit d'un email.
     if (!Tools::verifyEmail($receiver)) {
         throw new Exception("Invalid receiver email format.");
     }
     // Vérifie que l'utilisateur existe.
     $su = User::findByEmail($sender);
     if ($su == null) {
         throw new Exception("Invalid email sender.");
     }
     // Vérifie que l'utilisateur existe.
     $ru = User::findByEmail($receiver);
     if ($ru == null) {
         throw new Exception("Invalid email receiver.");
     }
     try {
         // Effectue une connexion à la DB.
         $pdo = DBconnect();
         // Commence la transaction.
         $pdo->beginTransaction();
         // Prépare la requête.
         $stmt = $pdo->prepare("INSERT INTO t_message(subject, message, fk_sender, fk_receiver)\n\t\t\t\t\tVALUES (:subject, :message, :sender, :receiver)");
         $stmt->bindParam(":subject", $subject);
         $stmt->bindParam(":message", $texte);
         $stmt->bindParam(":sender", $su->getId());
         $stmt->bindParam(":receiver", $ru->getId());
         if ($stmt->execute()) {
             $pdo->commit();
         } else {
             throw new Exception();
         }
     } catch (Exception $e) {
         // Revient en arrière si une erreur c'est produite.
         $pdo->rollBack();
         // Envoie à nouveau une exception.
         throw new Exception("Create message aborted, an error occurated.");
     } finally {
         // Ferme le traitement.
         $stmt->closeCursor();
         // Ferme la connexion vers la base de donnée.
         $pdo = null;
     }
 }
开发者ID:xxxkikixxx,项目名称:sti_projet_2,代码行数:59,代码来源:fctmessages.php

示例11: catch

             $usr->setPassword($pwd);
         }
         $usr->setActif($actif)->setRight($right)->doUpdate();
     } catch (Exception $e) {
         $formValid = false;
         $errors["other"] = $e->getMessage();
     }
 } else {
     $type = "add";
     $formValid = true;
     // Vérifie email
     if (!Tools::verifyEmail($email)) {
         $formValid = false;
         $errors["email"] = "You must insert a valid email.";
     } else {
         if (User::findByEmail($email) != null) {
             $formValid = false;
             $errors["email"] = "Email address already used.";
         }
     }
     // Si mot de passe valide
     if (!Tools::verifyPassword($pwd)) {
         $formValid = false;
         $errors["pwd"] = "You must insert a valid password see password <a href=\"#\">hint</a>.";
     }
     if (Right::findByName($right) == null) {
         $formValid = false;
         $errors["right"] = "You must select a correct user right.";
     }
     if ($formValid) {
         try {
开发者ID:xxxkikixxx,项目名称:sti_projet_2,代码行数:31,代码来源:adminuser.php

示例12: saveAll

 /**
  *  Write a paper in the DB with all its dependent objects
  *
  */
 function saveAll()
 {
     $db = Zend_Db_Table::getDefaultAdapter();
     // Remove invalid characters
     $this->title = Config::removeMSQuotes(trim($this->title));
     $this->title = preg_replace("/[\n\r]/", "", $this->title);
     // First save the paper
     $this->save();
     // Save abstracts. Be very careful not to erase something
     $currentAbstracts = $this->initAbstracts();
     $asbtractSectionTbl = new AbstractSection();
     $abstractSections = $asbtractSectionTbl->fetchAll();
     foreach ($abstractSections as $abstractSection) {
         if (isset($this->_abstract[$abstractSection->id])) {
             $abstract = $this->_abstract[$abstractSection->id];
             $abstract->content = Config::removeMSQuotes(trim($abstract->content));
             $abstract->content = htmlSpecialChars($abstract->content, ENT_NOQUOTES);
             // Do not store optional and empty abstracts
             if (empty($abstract->content) and $abstractSection->mandatory == 'N') {
                 continue;
             }
             if (isset($currentAbstracts[$abstractSection->id])) {
                 // Already in the DB: just update
                 $currentAbstracts[$abstractSection->id]->content = $abstract->content;
                 $currentAbstracts[$abstractSection->id]->save();
             } else {
                 // This is a new row
                 $abstract->id_paper = $this->id;
                 $abstract->save();
             }
         }
     }
     // Clean the Author table for this paper.
     $db->query("DELETE FROM Author WHERE id_paper='{$this->id}'");
     // OK, now save the authors
     $user = new User();
     $authorTble = new Author();
     $i = 0;
     //     echo "Contact author: " . $this->_contactAuthor . "<br/>";
     foreach ($this->_authors as $author) {
         // Check that the user does not already exist
         $existingAuthor = $user->findByEmail($author->email);
         if (is_object($existingAuthor)) {
             // Change the values with those obtained from the form
             $existingAuthor->last_name = $author->last_name;
             $existingAuthor->first_name = $author->first_name;
             $existingAuthor->affiliation = $author->affiliation;
             $existingAuthor->country_code = $author->country_code;
             // Mark the user as an author
             $existingAuthor->addRole(User::AUTHOR_ROLE);
             $existingAuthor->save();
             $idUser = $existingAuthor->id;
         } else {
             // Ok, simply save the new author
             $author->addRole(User::AUTHOR_ROLE);
             $author->save();
             $idUser = $author->id;
         }
         // In all cases, insert in the Author table (link between User and Paper)
         $authorRow = $authorTble->createRow();
         if ($this->_contactAuthor == $i) {
             $contact = 'Y';
         } else {
             $contact = 'N';
         }
         $authorRow->setFromArray(array("id_paper" => $this->id, "id_user" => $idUser, "position" => $i + 1, "contact" => $contact));
         $authorRow->save();
         $i++;
     }
     // Clean the PaperAnswer table for this paper.
     $db->query("DELETE FROM PaperAnswer WHERE id_paper='{$this->id}'");
     // And, finally, save the answer to questions
     foreach ($this->_answers as $answer) {
         $answer->id_paper = $this->id;
         $answer->save();
     }
 }
开发者ID:camilorivera,项目名称:INNOVARE,代码行数:81,代码来源:PaperRow.php

示例13: foreach

	the fields were left blank then we post an error telling them which field 
	they forgot to fill in. We also check other things like making sure
	passwords match, the email and summoner names aren't taken. We also have
	password strength requirement. 
	*********************************/
if ($_POST) {
    $flag = false;
    //Required fields left blank
    foreach ($signup_user->required as $field) {
        if (empty($_POST[$field])) {
            $flag = true;
            $signup_user->errors[$field] = $signup_user->messages[$field];
        }
    }
    //If that email is in use, throw an error
    if ($signup_user->findByEmail($dbh, $_POST['email'])) {
        $flag = true;
        $signup_user->errors['email'] = "Email already in use";
    }
    if (isset($_POST['password']) && isset($_POST['password2'])) {
        //If the passwords don't match give an error
        if ($_POST['password'] != $_POST['password2']) {
            $flag = true;
            $signup_user->errors['password'] = "Passwords don't match";
        } else {
            if (!preg_match("#[A-Z]+#", $_POST['password'])) {
                $flag = true;
                $signup_user->errors['password'] .= " Password must include at least one capital letter ";
            }
            if (!preg_match("#[a-z]+#", $_POST['password'])) {
                $flag = true;
开发者ID:kelmo2,项目名称:leagueOfLegendsClubSite,代码行数:31,代码来源:signUp.php

示例14: header

    $user = $_SESSION['user'];
    //So die and redirect to the index
    if ($user->id) {
        header("Location: /");
        die;
    }
}
/*****************************
	If the username and password fields weren't 
	left blank, let the user attempt to sign in via 
	function call. If the function returns true, it was 
	the correct username and password
	******************************/
if (isset($_POST['email']) && isset($_POST['pw'])) {
    //If the username doesn't exist and their password matches the hashed password
    if ($login_user->findByEmail($dbh, $_POST['email']) != NULL && $login_user->login($_POST['pw'])) {
        $bool = "true";
    }
}
//If true, then they meet the requirements to log in
if ($bool == "true") {
    $summonerName = $login_user->username;
    //Call the function to check riots database
    $result = $champObj->findSummoner(rawurlencode($summonerName));
    //If the result is true, we found them and we store it in our db and fetch their rank to save that as well.
    if ($result) {
        $guy->username = ucfirst(strtolower($summonerName));
        //All lowercase except first letter
        $summonerName = str_replace(' ', '', $summonerName);
        $summonerName = strtolower($summonerName);
        $summonerId = $result[$summonerName]['id'];
开发者ID:kelmo2,项目名称:leagueOfLegendsClubSite,代码行数:31,代码来源:loginCtrl.php

示例15: json_encode

<?php

/**
 * Validate that the email is available when signing up
 */
// Initialisation
require_once 'includes/init.php';
$is_available = false;
// Make sure it's an Ajax request
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
    $is_available = User::findByEmail($_POST['email']) === NULL;
}
// Return the result, formatted as JSON
echo json_encode($is_available);
开发者ID:sunitha181288,项目名称:Signup-and-Login-From-Scratch-Using-PHP,代码行数:14,代码来源:validate_email.php


注:本文中的User::findByEmail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。