lip 19 tuntia sitten
vanhempi
sitoutus
02bd91c2bd
2 muutettua tiedostoa jossa 13 lisäystä ja 1 poistoa
  1. 12 0
      app/Helpers/helpers.php
  2. 1 1
      app/Http/Controllers/admin/User.php

+ 12 - 0
app/Helpers/helpers.php

@@ -2,6 +2,18 @@
 
 use Illuminate\Support\Facades\Lang;
 
+/**
+ * @notes 生成密码加密密钥
+ * @param string $plaintext
+ * @param string $salt
+ * @return string
+ * @author 段誉
+ * @date 2021/12/28 18:24
+ */
+function create_password(string $plaintext, string $salt = 'likeadmin') : string
+{
+    return md5($salt . md5($plaintext . $salt));
+}
 
 if (!function_exists('env')) {
     function env($key, $default = null)

+ 1 - 1
app/Http/Controllers/admin/User.php

@@ -34,7 +34,7 @@ class User extends Controller
             if (!$user) throw new Exception("用户不存在", HttpStatus::CUSTOM_ERROR);
 
             if (!empty($params['password'])) {
-                $user->password = password_hash($params['password'], PASSWORD_DEFAULT);
+                $user->password = create_password($params['password']);
                 $user->save();
             }
             if (!empty($params['payment_password'])) {