Skip to content

Commit

Permalink
Removes switching to anonymous user functionality in preparation to a…
Browse files Browse the repository at this point in the history
…dd register method
  • Loading branch information
Kyle Browning authored and Kyle Browning committed Apr 28, 2011
1 parent fd05ee0 commit 81009b2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
15 changes: 6 additions & 9 deletions resources/user_resource.inc
Original file line number Diff line number Diff line change
Expand Up @@ -205,26 +205,23 @@ function _user_resource_create($account) {
'pass2' => $account['pass'],
);
$form_state['values']['op'] = t('Create new account');

// reset to anonymous user
global $user;
$orig_user = $user;
session_save_session(FALSE);
$user = user_load(array('uid' => 0));

// execute the register form
drupal_execute('user_register', $form_state);

// find and store the new user into the form_state
$form_state['user'] = user_load(array('name' => $form_state['values']['name']));

// revert back to the original user.
$user = $orig_user;
session_save_session(TRUE);

// Error if needed.
if ($errors = form_get_errors()) {
return services_error(implode(" ", $errors), 406);
} else {
$user = array('uid' => $form_state['user']->uid);
if ($uri = services_resource_uri(array('user', $user['uid']))) {
$user['uri'] = $uri;
}
return $user;
}
return $form_state['user'];
}
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/ServicesResourceUserTests.test
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ class ServicesResourceUsertests extends ServicesWebtestCase {

$response = $this->servicesPost($this->endpoint->path . '/user', array('account' => $user));
$account = $response['body'];
$this->assertTrue(!empty($account->uid), t('User has been create successfully.'), 'UserResource: Create');
$this->assertTrue(!empty($account['uid']), t('User has been create successfully.'), 'UserResource: Create');

// Load user.
$user_load = user_load($account->uid);
$user_load = user_load($account['uid']);
$this->assertTrue(!empty($user_load), t('Newly created user has been loaded successfully.'), 'UserResource: Create');

// Try to create user without email.
Expand Down

0 comments on commit 81009b2

Please sign in to comment.