Yii Framework Forum: Problem With Autentication - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Problem With Autentication Trying to authenticate users against a mail server Rate Topic: -----

#1 User is offline   galopez 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 13-November 12
  • Location:Cienfuegos, Cienfuegos, Cuba

  Posted 13 February 2013 - 04:26 PM

Hi. I'm using the Swift Mailer extension to send emails and works perfect. Now I'm trying to authenticate the users of my application with the same credentials used for send emails. In UserIdentity component I set this code:

        public function authenticate()
	{
	    $SM = Yii::app()->swiftMailer;
 
	    // Get config
	    $mailHost = 'some.server.com';
	    $mailPort = 25;
	 
	    // New transport
	    $transport = $SM->smtpTransport($mailHost, $mailPort);

	    $transport->setUsername($this->username);
	    $transport->setPassword($this->password);
	    $transport->start();

	    if($transport->isStarted()){
		$this->errorCode=self::ERROR_NONE;
	    }else{
		$this->errorCode=self::ERROR_PASSWORD_INVALID;
	    }

	    $transport->stop();
			
	    return !$this->errorCode;
	}


When a user type good login credentials the users gets authenticated at the moment. But when there are typed wrong login credentials the proccess spends more time but at the end the user is correctly authenticated too. I don't know why this happen because emails are just sent when correct username and passwords are set up in the transport.

I know this is more a Swift Mailer related question than Yii one, but I need help and I have asked these question in other websites and absolutely nothing.

This idea is incorrect?
Can I do what I want?
Are $transport->start() and $transport->isStarted() useful methods to check if the user was correctly authenticated?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users