public function testFutureDate() { $datetime = DateUtils::inDays(1, 1405267200); $this->assertInternalType('string', $datetime); $expected = '2014-07-14 16:00:00'; $this->assertEquals($expected, $datetime); }
$message->setTo($user['email']); }); $app->halt(200, __t('password_reset_new_temporary_password_sent')); })->name('auth_reset_password'); $app->post("/{$v}/auth/forgot-password/?", function () use($app, $acl, $ZendDb) { if (!isset($_POST['email'])) { return JsonView::render(['success' => false, 'message' => __t('password_forgot_invalid_email')]); } $DirectusUsersTableGateway = new DirectusUsersTableGateway($acl, $ZendDb); $user = $DirectusUsersTableGateway->findOneBy('email', $_POST['email']); if (false === $user) { return JsonView::render(['success' => false, 'message' => __t('password_forgot_no_account_found')]); } $set = []; $set['reset_token'] = StringUtils::randomString(30); $set['reset_expiration'] = DateUtils::inDays(2); // Skip ACL $DirectusUsersTableGateway = new \Zend\Db\TableGateway\TableGateway('directus_users', $ZendDb); $affectedRows = $DirectusUsersTableGateway->update($set, ['id' => $user['id']]); if (1 !== $affectedRows) { return JsonView::render(['success' => false]); } $data = ['reset_token' => $set['reset_token']]; Mail::send('mail/reset-password.twig.html', $data, function ($message) use($user) { $message->setSubject(__t('password_forgot_password_reset_email_subject')); $message->setTo($user['email']); }); $success = true; return JsonView::render(['success' => $success]); })->name('auth_permissions'); // debug helper