Zum Inhalt springen

Login und Userhandling

Erstellt am 21. Februar 2013 · 5 Antworten · letzte Antwort am 1. Juli 2013

Tags: Frage

Freshmeat ·

Hallo Forum

Ich benötige Hilfe beim Login und Userhandling.
Bereits abhacken kann ich folgende Punkte die bereits funktionieren:
- Registrierung eines neuen Benutzers
- Login

Und was ich jetzt eigentlich machen möchte ist, denn eingeloggten Benutzer auf einer Seite darstellen.
Hört sich einfach an... aber irgendwie passiert gar nichts.

Meinen Account-Controller

namespace WS\Rico\Controller;

/*                                                                        *
 * This script belongs to the TYPO3 Flow package "WS.Rico".               *
 *                                                                        *
 *                                                                        */

use WS\Rico\Domain\Model\User;

use TYPO3\Flow\Annotations as Flow;

/**
 * Account controller for the WS.Rico package 
 *
 * @Flow\Scope("singleton")
 */
class AccountController extends \TYPO3\Flow\Mvc\Controller\ActionController {
	
	/**
	 * @Flow\Inject
	 * @var \TYPO3\Flow\Security\AccountRepository
	 */
	protected $accountRepository;

	/**
	 * @var \TYPO3\Flow\Security\Context
	 * @Flow\Inject
	 */
	protected $securityContext; 
	
	/**
	 * @var \TYPO3\Flow\Security\Policy\PolicyService
	 * @Flow\Inject
	 */
	protected $policyService;
	
	/**
	 * Injects the security context
	 *
	 * @param \TYPO3\Flow\Security\Context $securityContext The security context
	 * @return void
	 */
	public function injectSecurityContext(\TYPO3\Flow\Security\Context $securityContext) {
		$this->securityContext = $securityContext;
	}
	
	/**
	 * @Flow\Inject
	 * @var \TYPO3\Flow\Security\AccountFactory
	 */
	protected $accountFactory;

	/**
	 * @Flow\Inject
	 * @var \WS\Rico\Domain\Repository\UserRepository
	 */
	protected $userRepository;

	/**
	 * Index action
	 *
	 * @return void
	 */
	public function indexAction() {
		
		$accounts = $this->accountRepository->findAll();		
		$account = $this->securityContext->getAccount();

		$this->view->assign('account', $account);
		$this->view->assign('accounts', $accounts);	
		
	}
		
}

In Fluid erhalte ich keinerlei Ausgabe. Bei Accounts welche ich mit einer Foreach durchlaufe wie auch bei Account wird nichts ausgegeben.

Kann mir jemand einen Tipp geben?

Da ich wahrscheinlich noch weiter mit Problemen kämpfen werde, könnte ich ein bisschen Hilfe brauchen. Gibt es jemanden der sich bereit erklären würde mir bei Fragen beizustehen (z.B. per Skype). Bezahlung für diesen Dienst wäre auch möglich.

Freshmeat ·

Update von meiner Seite.

Es ist in Flow nicht möglich eine andere Verknüpfung zum Account aufzubauen als über das Party-Modul das mit Flow mitgeliefert wird. Folglich musste ich mein Model auf die Basis der AbstractParty-Class stellen.

<?php
namespace WS\Rico\Domain\Model;

/*                                                                        *
 * This script belongs to the TYPO3 Flow package "WS.Rico".               *
 *                                                                        *
 *                                                                        */

use Doctrine\ORM\Mapping as ORM;
use TYPO3\Flow\Annotations as Flow;

/**
 * An user
 *
 * @Flow\Entity
 */
class User extends \TYPO3\Party\Domain\Model\AbstractParty {
	
	/**
	 * @var string
	 * @Flow\Validate(type="NotEmpty")
	 * @Flow\Validate(type="StringLength", options={ "minimum"=1, "maximum"=1 })
	 */
	protected $gender;

	/**
	 * @var string
	 * @Flow\Validate(type="NotEmpty")
	 * @Flow\Validate(type="StringLength", options={ "minimum"=2, "maximum"=100 })
	 */
	protected $firstName;

	/**
	 * @var string
	 * @Flow\Validate(type="NotEmpty")
	 * @Flow\Validate(type="StringLength", options={ "minimum"=2, "maximum"=100 })
	 */
	protected $lastName;

	/**
	 * @var string
	 * @Flow\Validate(type="NotEmpty")
	 * @Flow\Validate(type="EmailAddress")
	 */
	protected $emailBusiness;

	/**
	 * @var string
	 * @Flow\Validate(type="EmailAddress")
	 */
	protected $emailPrivate = '';

	/**
	 * @var string
	 * @Flow\Validate(type="NotEmpty")
	 * @Flow\Validate(type="StringLength", options={ "minimum"=5, "maximum"=100 })
	 */
	protected $phoneBusiness;

	/**
	 * @var string
	 * @Flow\Validate(type="StringLength", options={ "minimum"=5, "maximum"=100 })
	 */
	protected $phonePrivate = '';

	/**
	 * @var string
	 */
	protected $registrationData = '';


	/**
	 * Constructs this user
	 *
	 */
	public function __construct() {
		parent::__construct();
	}

	/**
	 * Setter for firstName
	 *
	 * @param string $firstName
	 * @return void
	 */
	public function setFirstName($firstName) {
		$this->firstName = $firstName;
	}

	/**
	 * Getter for firstName
	 *
	 * @return string
	 */
	public function getFirstName() {
		return $this->firstName;
	}

	...
	
}
BlackPixel ·

Nein, musst Du nicht?!

ich nutze die Account Class von FLOW, hab ein eigenes Model mit den Userproperties, und das funktioniert 1a. Das Listing Zäune ich in dem Fall anders herum auf. ich geh auf meine UserRepository anstatt die accounts zu listen. Bei mir steht der User im Vordergrund, und nicht der Account. Aber bei der Registrierung wird eben beides angelegt und verknüpft.

Schau hier:

User Model:
http://pastebin.com/6nS6nquk

Login Controller:
http://pastebin.com/AnhMv3F9

User Controller:
http://pastebin.com/CuHReYtH

Hoffe Du kommst mit dem Code weiter :-)

Freshmeat ·

Hallo BlackPixel

Danke für deinen Code. Jetzt wo ich Ihn mir so anschaue, eigentlich logisch das dies auch funktionieren muss.

PeterWadson ·

Gibt es zu dem AuthenticationManagerInterface eigentlich eine offizielle Documentation von Flow3 selbst? Wenn ja, wo?

Grüße, Pete