function blogapi_validate_user in Blog API 7.2
Same name and namespace in other branches
- 7 blogapi.module \blogapi_validate_user()
Ensure that a given user has permission to use BlogAPI
11 calls to blogapi_validate_user()
- blogapi_blogger_delete_post in modules/
blogapi_blogger/ blogapi_blogger.module - Service callback for blogger.deletePost
- blogapi_blogger_get_post in modules/
blogapi_blogger/ blogapi_blogger.module - Service callback for blogger.getPost
- blogapi_blogger_get_users_blogs in modules/
blogapi_blogger/ blogapi_blogger.module - Service callback for blogger.getUsersBlogs
- blogapi_blogger_get_user_info in modules/
blogapi_blogger/ blogapi_blogger.module - Service callback for blogger.getUserInfo
- blogapi_edit_post in ./
blogapi.module - Service allback for metaWeblog.editPost
File
- ./
blogapi.module, line 67 - Enable users to post using applications that support BlogAPIs.
Code
function blogapi_validate_user($username, $password) {
global $user;
// Check the username and password.
$uid = user_authenticate($username, $password);
if (is_numeric($uid)) {
$user = user_load($uid);
if ($user->uid) {
user_login_finalize();
services_remove_user_data($user);
if (user_access('manage content with blogapi', $user)) {
// User has appropriate permissions.
return $user;
}
else {
return services_error(t('You do not have permission to edit this blog'), 405);
}
}
}
watchdog('user', 'Invalid login attempt for %username.', array(
'%username' => $username,
));
return services_error(t('Invalid username or password'), 401);
}