mirror of
https://github.com/grocy/grocy.git
synced 2026-04-07 05:16:15 +02:00
Add email for users
This commit is contained in:
parent
6f4769a7b3
commit
da2d2db4fe
|
|
@ -74,6 +74,14 @@ Setting('DISABLE_BROWSER_BARCODE_CAMERA_SCANNING', false);
|
||||||
# Needs to be a number where Sunday = 0, Monday = 1 and so forth
|
# Needs to be a number where Sunday = 0, Monday = 1 and so forth
|
||||||
Setting('MEAL_PLAN_FIRST_DAY_OF_WEEK', '');
|
Setting('MEAL_PLAN_FIRST_DAY_OF_WEEK', '');
|
||||||
|
|
||||||
|
# Email smtp settings
|
||||||
|
Setting('EMAIL_HOST','smtp.gmail.com');
|
||||||
|
Setting('EMAIL_PORT','587');
|
||||||
|
Setting('EMAIL_USERNAME','');
|
||||||
|
Setting('EMAIL_PASSWORD','');
|
||||||
|
Setting('EMAIL_FROM','from@example.com, from who');
|
||||||
|
Setting('EMAIL_REPLYTO','noreply@example.com, No Reply');
|
||||||
|
|
||||||
|
|
||||||
# Default user settings
|
# Default user settings
|
||||||
# These settings can be changed per user, here the defaults
|
# These settings can be changed per user, here the defaults
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ class UsersApiController extends BaseApiController
|
||||||
throw new \Exception('Request body could not be parsed (probably invalid JSON format or missing/wrong Content-Type header)');
|
throw new \Exception('Request body could not be parsed (probably invalid JSON format or missing/wrong Content-Type header)');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->getUsersService()->CreateUser($requestBody['username'], $requestBody['first_name'], $requestBody['last_name'], $requestBody['password']);
|
$this->getUsersService()->CreateUser($requestBody['username'], $requestBody['email'], $requestBody['first_name'], $requestBody['last_name'], $requestBody['password']);
|
||||||
return $this->EmptyApiResponse($response);
|
return $this->EmptyApiResponse($response);
|
||||||
}
|
}
|
||||||
catch (\Exception $ex)
|
catch (\Exception $ex)
|
||||||
|
|
@ -60,7 +60,7 @@ class UsersApiController extends BaseApiController
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$this->getUsersService()->EditUser($args['userId'], $requestBody['username'], $requestBody['first_name'], $requestBody['last_name'], $requestBody['password']);
|
$this->getUsersService()->EditUser($args['userId'], $requestBody['username'], $requestBody['email'], $requestBody['first_name'], $requestBody['last_name'], $requestBody['password']);
|
||||||
return $this->EmptyApiResponse($response);
|
return $this->EmptyApiResponse($response);
|
||||||
}
|
}
|
||||||
catch (\Exception $ex)
|
catch (\Exception $ex)
|
||||||
|
|
|
||||||
|
|
@ -40,3 +40,13 @@ JOIN stock s
|
||||||
WHERE pr.parent_product_id != pr.sub_product_id
|
WHERE pr.parent_product_id != pr.sub_product_id
|
||||||
GROUP BY pr.sub_product_id
|
GROUP BY pr.sub_product_id
|
||||||
HAVING SUM(s.amount) > 0;
|
HAVING SUM(s.amount) > 0;
|
||||||
|
|
||||||
|
ALTER TABLE users
|
||||||
|
ADD email TEXT;
|
||||||
|
|
||||||
|
CREATE TABLE password_reset_temp (
|
||||||
|
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
|
||||||
|
email TEXT NOT NULL UNIQUE,
|
||||||
|
key TEXT,
|
||||||
|
expiration_date DATETIME NOT NULL
|
||||||
|
);
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,11 @@ namespace Grocy\Services;
|
||||||
|
|
||||||
class UsersService extends BaseService
|
class UsersService extends BaseService
|
||||||
{
|
{
|
||||||
public function CreateUser(string $username, string $firstName, string $lastName, string $password)
|
public function CreateUser(string $username, string $email, string $firstName, string $lastName, string $password)
|
||||||
{
|
{
|
||||||
$newUserRow = $this->getDatabase()->users()->createRow(array(
|
$newUserRow = $this->getDatabase()->users()->createRow(array(
|
||||||
'username' => $username,
|
'username' => $username,
|
||||||
|
'email' => $email,
|
||||||
'first_name' => $firstName,
|
'first_name' => $firstName,
|
||||||
'last_name' => $lastName,
|
'last_name' => $lastName,
|
||||||
'password' => password_hash($password, PASSWORD_DEFAULT)
|
'password' => password_hash($password, PASSWORD_DEFAULT)
|
||||||
|
|
@ -15,7 +16,7 @@ class UsersService extends BaseService
|
||||||
$newUserRow->save();
|
$newUserRow->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function EditUser(int $userId, string $username, string $firstName, string $lastName, string $password)
|
public function EditUser(int $userId, string $username, string $email, string $firstName, string $lastName, string $password)
|
||||||
{
|
{
|
||||||
if (!$this->UserExists($userId))
|
if (!$this->UserExists($userId))
|
||||||
{
|
{
|
||||||
|
|
@ -25,6 +26,7 @@ class UsersService extends BaseService
|
||||||
$user = $this->getDatabase()->users($userId);
|
$user = $this->getDatabase()->users($userId);
|
||||||
$user->update(array(
|
$user->update(array(
|
||||||
'username' => $username,
|
'username' => $username,
|
||||||
|
'email' => $email,
|
||||||
'first_name' => $firstName,
|
'first_name' => $firstName,
|
||||||
'last_name' => $lastName,
|
'last_name' => $lastName,
|
||||||
'password' => password_hash($password, PASSWORD_DEFAULT)
|
'password' => password_hash($password, PASSWORD_DEFAULT)
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,12 @@
|
||||||
<div class="invalid-feedback">{{ $__t('A username is required') }}</div>
|
<div class="invalid-feedback">{{ $__t('A username is required') }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="email">{{ $__t('Email') }}</label>
|
||||||
|
<input type="text" class="form-control" required id="email" name="email" value="@if($mode == 'edit'){{ $user->email }}@endif">
|
||||||
|
<div class="invalid-feedback">{{ $__t('An email is required') }}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="first_name">{{ $__t('First name') }}</label>
|
<label for="first_name">{{ $__t('First name') }}</label>
|
||||||
<input type="text" class="form-control" id="first_name" name="first_name" value="@if($mode == 'edit'){{ $user->first_name }}@endif">
|
<input type="text" class="form-control" id="first_name" name="first_name" value="@if($mode == 'edit'){{ $user->first_name }}@endif">
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th class="border-right"></th>
|
<th class="border-right"></th>
|
||||||
<th>{{ $__t('Username') }}</th>
|
<th>{{ $__t('Username') }}</th>
|
||||||
|
<th>{{ $__t('Email') }}</th>
|
||||||
<th>{{ $__t('First name') }}</th>
|
<th>{{ $__t('First name') }}</th>
|
||||||
<th>{{ $__t('Last name') }}</th>
|
<th>{{ $__t('Last name') }}</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
@ -48,6 +49,9 @@
|
||||||
<td>
|
<td>
|
||||||
{{ $user->username }}
|
{{ $user->username }}
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ $user->email }}
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{ $user->first_name }}
|
{{ $user->first_name }}
|
||||||
</td>
|
</td>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user