Commit e4daddd4 authored by Thomas Citharel's avatar Thomas Citharel 🌲

Merge branch 'grav-gravatar' into 'framasites'

Grav gravatar

See merge request framasoft/framasite!18
parents 52ff566c 604eca80
Pipeline #26085 failed with stage
in 24 minutes and 50 seconds
......@@ -254,6 +254,23 @@ class AsyncAccountGrav extends AbstractMakeAccount implements AsyncAccountInterf
$this->checkAccount();
$admin = $this->siteUser->isAdmin();
$fs = new Filesystem();
/**
* Eventutally create the avatars folder
*/
$avatarsPath = $this->accountsPath . '/' . $this->site->getSubdomain() . '/user/accounts/avatars/';
if (!$fs->exists($avatarsPath)) {
$fs->mkdir($avatarsPath);
}
/**
* Copy avatar
*/
$avatarPath = 'user/accounts/avatars/xVTJub3GlASrgzw.jpg';
$fs->copy($this->enginePath . '/' . $avatarPath, $avatarsPath . 'xVTJub3GlASrgzw.jpg');
$userData = [
'hashed_password' => password_hash($this->siteUser->getPassword(), PASSWORD_DEFAULT),
'email' => $this->user->getEmail(),
......@@ -284,6 +301,14 @@ class AsyncAccountGrav extends AbstractMakeAccount implements AsyncAccountInterf
],
'fullname' => $this->siteUser->getUsername(),
'state' => 'enabled',
'avatar' => [
$avatarPath => [
'name' => $this->siteUser->getUsername() . '.jpg',
'type' => 'image/jpeg',
'size' => 62518,
'path' => $avatarPath
]
]
];
$yamlData = Yaml::dump($userData, 3);
file_put_contents($this->accountsPath . '/' . $this->site->getSubdomain() . '/user/accounts/' . $this->siteUser->getUsername() . '.yaml', $yamlData);
......
......@@ -13,7 +13,7 @@ class AbstractSiteUser
/**
* @var string
* @Assert\NotBlank()
* @Assert\Regex(pattern="/^[a-z0-9]+$/", message="site.new.user.info.lowercase_username")
* @Assert\Regex(pattern="/^[a-z0-9]+$/", message="site.user.lowercase_username")
*/
protected $username;
......
......@@ -21,6 +21,7 @@ site:
password:
match: Les mots de passe doivent correspondre entre eux
too_short: Le mot de passe doit faire au minimum {{ limit }} caractères
lowercase_username: Votre identifiant doit contenir uniquement des caractères alphanumériques. Les majuscules ne sont pas autorisées.
settings:
password:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment