Log message #4200374

# At Username Text
# Aug 29th 2019, 11:24 ndm It depends on where exactly the exception is thrown, if it's thrown from the component, then it means that the authentication middleware didn't run, because the `identity` attribute on the request is missing.
# Aug 29th 2019, 11:22 alexdd55976 oh.. or does it mean: everything works, but user is not authenticated?
# Aug 29th 2019, 11:21 alexdd55976 @ndm i do this ` $this->loadComponent("Authentication.Authentication");` but get the message `Authentication is required to continue`
# Aug 29th 2019, 11:18 alexdd55976 so, actually you are already there
# Aug 29th 2019, 11:18 slackebot2 self-containing. As mentioned, `$this->Authentication` refers to the authentication component, it's initialized via `Controller::loadComponent()`. https://book.cakephp.org/authentication/1.1/en/index.html#authentication-component
# Aug 29th 2019, 11:18 ndm @alexdd55976 `$request` comes from wherever it is intended to come from depending on the context where your code runs, in a middleware it's passed to the `__invoke()` method, in controllers and views there's the `getRequest()` method, in components you can retrieve it via the the controller that the component is attached to... The examples in the documentation often rely a bit on a certain familiarity with the framework, and aren't neccesarily
# Aug 29th 2019, 11:18 alexdd55976 if you do no submitting to a different action, you stay in that action
# Aug 29th 2019, 11:16 davorminchorov hmm, that's a good point, did not think of it. What's a good way to get back on the same page?
# Aug 29th 2019, 11:15 alexdd55976 why you redirect? isn't that clearing the variables?
# Aug 29th 2019, 11:14 slackebot2 ($numberOfValidationErrors > 0) { $this->set('transitionValidationErrors', $transitionValidationErrors); return $this->redirect($this->referer()); } ```
# Aug 29th 2019, 11:14 davorminchorov @alexdd55976 This is what I do: ``` $people = $this->Persons->newEntities($preparedTransitionsData); $people = $this->Persons->patchEntities($people, $preparedTransitionsData, [ 'validate' => 'add' ]); $numberOfValidationErrors = 0; $transitionValidationErrors = []; foreach($people as $key => $person) { $numberOfValidationErrors += count($person->getErrors()); $transitionValidationErrors[$key] = $person->getErrors(); } if
# Aug 29th 2019, 11:09 alexdd55976 you can use this as a example
# Aug 29th 2019, 11:08 alexdd55976 this is what i do with manuel validation
# Aug 29th 2019, 11:08 slackebot2 'missing key: ends_time (format: HH:MM:SS)'); $errors = []; if ($validator->errors($this->request->getData()) != null) { $errors = array_merge($errors, $this->restructureValidationMessages($validator->errors($data))); } ```
# Aug 29th 2019, 11:08 slackebot2 ->requirePresence('title', ['mode' => true], 'missing key: title') ->requirePresence('starts', ['mode' => true], 'missing key: starts (format: YYYY-MM-DD)') ->requirePresence('starts_time', ['mode' => true], 'missing key: starts_time (format: HH:MM:SS)') ->requirePresence('ends', ['mode' => true], 'missing key: ends (format: YYYY-MM-DD)') ->requirePresence('ends_time', ['mode' => true],
# Aug 29th 2019, 11:08 slackebot2 'create', 'message' => 'missing key: eventtype_id', ], 'location' => [ 'mode' => 'create', 'message' => 'missing key: location' ] ]) ->numeric('eventtype_id') ->greaterThanOrEqual('longitude', 0, 'longitude must be 0 or greater') ->greaterThanOrEqual('latitude', 0, 'latitude must be 0 or greater')
# Aug 29th 2019, 11:08 alexdd55976 @davorminchorov ``` $validator = new Validator(); $validator ->requirePresence('company_id', ['mode' => true], 'missing key: company_id') ->requirePresence('organization_id', ['mode' => true], 'missing key: organization_id') // ->requirePresence('user_id', ['mode' => true], 'missing key: user_id') ->requirePresence([ 'eventtype_id' => [ 'mode' =>
# Aug 29th 2019, 11:08 challgren try `$model = $this->Model->patchEntities(); $this->set('errors', $model->getErrors());`
# Aug 29th 2019, 11:04 slackebot2 $errors)` but I had no luck, it showed up as null in the view so I couldn't display any data.
# Aug 29th 2019, 11:04 davorminchorov Hi, I implemented form validation using `$this->Model->newEntitites()` and `$this->Model->patchEntities()` and now I want to display all of those errors in a list in the view if there are any errors. My forms do not use the form helper / plugin (`$this->Form`) which I believe that's done automatically if done by convention. Any ideas how can I implement that? I tried passing the array of errors to the view using `$this->set('errors',
# Aug 29th 2019, 10:59 alexdd55976 the docu does not tell where its "constructed" its just used later ... know idea wher eit comes from
# Aug 29th 2019, 10:59 alexdd55976 i do not even know where its coming from. there is a `$authentication`variable used in the middleware method, but of course this is not available in the user controller
# Aug 29th 2019, 10:51 conehead not sure, but can't you just throw an exception in the constructor and print out the stacktrace?
# Aug 29th 2019, 10:50 alexdd55976 can anyone pls help with that?
# Aug 29th 2019, 09:50 javier.villanueva I understood that you want a model without table associated, but you want no override its table
# Aug 29th 2019, 09:49 javier.villanueva Mmm sorry, I didnt know this option
# Aug 29th 2019, 09:48 neon1024 That’ll work too
# Aug 29th 2019, 09:48 challgren Well easiest I found was `bin/cake bake model Devices` and not overwrite the table
# Aug 29th 2019, 09:47 neon1024 `bin/cake bake model --no-table --no-test --no-fixture Examples`
# Aug 29th 2019, 09:47 neon1024 @challgren Yes you can bake just an entity
# Aug 29th 2019, 09:47 alexdd55976 @admad @ndm in the docs i found `$request->getAttribute('identity');`where is `$request`coming from? it is nowhere initialized in the docs..
# Aug 29th 2019, 09:37 alexdd55976 and still a riddle where `$this->Authentication` is initated
# Aug 29th 2019, 09:37 alexdd55976 but of course its not working
# Aug 29th 2019, 09:36 alexdd55976 somehow.. i tries to authenticate...
# Aug 29th 2019, 09:31 javier.villanueva @challgren I think not possible in 3.x
# Aug 29th 2019, 09:30 alexdd55976 the old auth component seems not to be the one
# Aug 29th 2019, 09:30 alexdd55976 @ndm `Authentication is required to continue` .. but there is no authentication component.
# Aug 29th 2019, 09:30 challgren I wanted to be lazy!
# Aug 29th 2019, 09:30 challgren Yeah I just did it manually
# Aug 29th 2019, 09:30 javier.villanueva I think that cake not support it
# Aug 29th 2019, 09:27 challgren Not table