示例#1
0
    /**
     * Sends an email with a link, for resetting the password.
     *
     * @return boolean whether the email was send
     */
    public function sendEmail()
    {
        /* @var $user  from User validator user variable */

        $user = $this->validators[2]->user;
        Auction::info('User is ready to sent a new Token');

        switch ($this->via){
            case 'email' :
                ForgotPasswordHistory::model()->generateOtp($user);
                break;

            case 'sms':
                OptHistory::model()->generateOtp($user);
        }
        return false;
    }
示例#2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getOptHistories()
 {
     return $this->hasMany(OptHistory::className(), ['user' => 'id']);
 }
示例#3
0
    /** Send Reset Token */
    public static function SendResetToken($event){
        $message = '';
        switch ($event->sender->mode){

            case DatabaseHelper::TOKEN_SEND_MODE_WEB:
                $message = MessageTemplate::MessageTemplate(DatabaseHelper::FORGOT_PASSWORD_MAIL_TEMPLATE);
                $_model = new AuctionEmails();
                $_model->to = $event->sender->userObject->email;
                $_model->subject = 'Auction :: Reset Password Email';
                $_model->status = 0 ;
                $_model->from = 'Auction';
                break;

            case DatabaseHelper::TOKEN_SEND_MODE_MOBILE:
                $message = MessageTemplate::MessageTemplate(DatabaseHelper::FORGOT_PASSWORD_SMS_TEMPLATE);
                $_model = new OptHistory();
                $_model->mobile = $event->sender->userObject->mobile;
                break;
        }
        if($message == ''){
            Auction::error('No Valid Msg Template Found For ' .$event->sender->mode.' in database');
            throw new HttpException(400 , 'No Template Found');
        }

        $_model->message = $message;

        if($_model->save()){
            Auction::info('User Token successfully Created');
        }else {
            $_message = Auction::loggerMessageFormat('User reset token template invalid ',$_model->getErrors());
            Auction::error($_message);
        }
    }