Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Σταύρος Παπαδάκης
gredu_labs
Commits
7bb4c62f
Commit
7bb4c62f
authored
Feb 10, 2016
by
Vassilis Kanellopoulos
Browse files
validate when loging from database; phpCS
parent
02beb04b
Changes
3
Hide whitespace changes
Inline
Side-by-side
module/authentication/src/Adapter/RedBeanPHP.php
View file @
7bb4c62f
...
...
@@ -49,11 +49,18 @@ class RedBeanPHP extends AbstractAdapter
$events
=
$this
->
events
;
$events
(
'trigger'
,
'authenticate'
,
$this
);
$user
=
R
::
findOne
(
'user'
,
'mail = ? AND authentication_source = ?'
,
[
$this
->
getIdentity
(),
'DB'
,
$email
=
filter_var
(
$this
->
getIdentity
(),
FILTER_VALIDATE_EMAIL
);
$isValidCredential
=
filter_var
(
strlen
(
trim
(
$this
->
getCredential
())),
FILTER_VALIDATE_INT
,
[
'options'
=>
[
'min_range'
=>
8
],
]);
if
(
!
$email
||
!
$isValidCredential
)
{
return
new
Result
(
Result
::
FAILURE_CREDENTIAL_INVALID
,
null
,
[
self
::
$failMessage
]);
}
$user
=
R
::
findOne
(
'user'
,
'mail = ? AND authentication_source = ?'
,
[
$email
,
'DB'
]);
if
(
!
$user
)
{
return
new
Result
(
Result
::
FAILURE_IDENTITY_NOT_FOUND
,
null
,
[
self
::
$failMessage
]);
}
...
...
module/sch_mm/bootstrap.php
View file @
7bb4c62f
...
...
@@ -19,10 +19,10 @@ return function (Slim\App $app) {
return
new
SchMM\FetchUnit
(
new
GuzzleHttp\Client
([
'base_uri'
=>
$settings
[
'sch_mm'
][
'api_url'
],
'auth'
=>
[
$settings
[
'sch_mm'
][
'api_user'
],
'auth'
=>
[
$settings
[
'sch_mm'
][
'api_user'
],
$settings
[
'sch_mm'
][
'api_pass'
],
],
]));
};
};
\ No newline at end of file
};
module/sch_mm/src/FetchUnit.php
View file @
7bb4c62f
...
...
@@ -31,16 +31,17 @@ class FetchUnit
public
function
__invoke
(
$mmId
)
{
$config
=
$this
->
httpClient
->
getConfig
();
$baseUri
=
$config
[
'base_uri'
];
$auth
=
$config
[
'auth'
];
$url
=
$baseUri
->
withQueryValue
(
$baseUri
,
'registry_no'
,
$mmId
);
$config
=
$this
->
httpClient
->
getConfig
();
$baseUri
=
$config
[
'base_uri'
];
$auth
=
$config
[
'auth'
];
$url
=
$baseUri
->
withQueryValue
(
$baseUri
,
'registry_no'
,
$mmId
);
$response
=
$this
->
httpClient
->
request
(
'GET'
,
$url
,
[
'auth'
=>
$auth
]);
$responseData
=
json_decode
(
$response
->
getBody
()
->
getContents
(),
true
);
if
(
!
isset
(
$responseData
[
'data'
])
||
empty
(
$responseData
[
'data'
]))
{
return
null
;
return
;
}
return
$responseData
[
'data'
][
0
];
}
}
\ No newline at end of file
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment