修改相关业务操作数据文件,对用户注册和增加用户暂时进行md5加密,然后存入到数据表中
This commit is contained in:
parent
f807eb10fd
commit
c9845b7552
|
|
@ -24,10 +24,10 @@ http {
|
|||
# The verification depth in the server certificates chain.
|
||||
#lua_ssl_verify_depth 3;
|
||||
|
||||
# 在 Nginx 启动时执行的 Lua 代码块
|
||||
#在Nginx启动时执行的Lua代码块
|
||||
lua_shared_dict dict_a 1m;
|
||||
init_by_lua_block {
|
||||
-- 定义一个全局变量
|
||||
-- 定义一个全局变量
|
||||
ngx.log(ngx.INFO, "Initializing global variable")
|
||||
global_var = "Hello, Nginx with Lua!"
|
||||
|
||||
|
|
@ -35,8 +35,8 @@ http {
|
|||
local shared_dict = ngx.shared.dict_a
|
||||
shared_dict:set("key", "value")
|
||||
}
|
||||
|
||||
#下面代码不能与上面的代码进行共用,否则报错nginx: [emerg] "init_by_lua_file" directive is duplicate
|
||||
#init_by_lua_block 与 init_by_lua_file 只能初始化其中的一个,不能同时启用
|
||||
#否则报错nginx: [emerg] "init_by_lua_file" directive is duplicate
|
||||
#init_by_lua_file '/home/frankly/work/AuthPlatform/src/init.lua';
|
||||
|
||||
server {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ local systemAccount = require("service.system.account")
|
|||
|
||||
--定义相关路由,前端接口url地址
|
||||
local routes = {
|
||||
--用户相关路由接口
|
||||
--账户相关路由接口
|
||||
{
|
||||
paths = { "/api/system/accounts" },
|
||||
methods = { "GET" },
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ local systemApplication = require("service.system.application")
|
|||
|
||||
--定义相关路由,前端接口url地址
|
||||
local routes = {
|
||||
--用户相关路由接口
|
||||
--应用相关路由接口
|
||||
{
|
||||
paths = { "/api/system/applications" },
|
||||
methods = { "GET" },
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ local systemDepartment = require("service.system.department")
|
|||
|
||||
--定义相关路由,前端接口url地址
|
||||
local routes = {
|
||||
--用户相关路由接口
|
||||
--组织(部门)相关路由接口
|
||||
{
|
||||
paths = { "/api/system/departments" },
|
||||
methods = { "GET" },
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ local systemMenu = require("service.system.menu")
|
|||
|
||||
--定义相关路由,前端接口url地址
|
||||
local routes = {
|
||||
--用户相关路由接口
|
||||
--菜单相关路由接口
|
||||
{
|
||||
paths = { "/api/system/menus" },
|
||||
methods = { "GET" },
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ local systemPermission = require("service.system.permission")
|
|||
|
||||
--定义相关路由,前端接口url地址
|
||||
local routes = {
|
||||
--用户相关路由接口
|
||||
--权限相关路由接口
|
||||
{
|
||||
paths = { "/api/system/permissions" },
|
||||
methods = { "GET" },
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ local systemPosition = require("service.system.position")
|
|||
|
||||
--定义相关路由,前端接口url地址
|
||||
local routes = {
|
||||
--用户相关路由接口
|
||||
--岗位相关路由接口
|
||||
{
|
||||
paths = { "/api/system/positions" },
|
||||
methods = { "GET" },
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ local systemRole = require("service.system.role")
|
|||
|
||||
--定义相关路由,前端接口url地址
|
||||
local routes = {
|
||||
--用户相关路由接口
|
||||
--角色相关路由接口
|
||||
{
|
||||
paths = { "/api/system/roles" },
|
||||
methods = { "GET" },
|
||||
|
|
|
|||
|
|
@ -20,18 +20,19 @@ local function authenticate(name, passwd)
|
|||
if passwd == "" then
|
||||
return 0x010002, nil
|
||||
end
|
||||
local pwdMd5 = ngx.encode_md5(passwd)
|
||||
--根据用户进行验证用户是否存在
|
||||
local code, res = userModel:where("username", "=", name):where("password", "=", passwd):get()
|
||||
local code, res = userModel:where("username", "=", name):where("password", "=", pwdMd5):get()
|
||||
if code == 0 and res ~= nil then
|
||||
return code, res
|
||||
end
|
||||
--根据手机号进行验证用户是否存在
|
||||
code, res = userModel:where("phone", "=", name):where("password", "=", passwd):get()
|
||||
code, res = userModel:where("phone", "=", name):where("password", "=", pwdMd5):get()
|
||||
if code == 0 and res ~= nil then
|
||||
return code, res
|
||||
end
|
||||
--根据邮箱进行验证用户是否存在
|
||||
code, res = userModel:where("email", "=", name):where("password", "=", passwd):get()
|
||||
code, res = userModel:where("email", "=", name):where("password", "=", pwdMd5):get()
|
||||
if code == 0 and res ~= nil then
|
||||
return code, res
|
||||
end
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ local _M = {}
|
|||
local user = {
|
||||
["ID"] = "",
|
||||
["type"] = 0,
|
||||
|
||||
}
|
||||
|
||||
--判断用户是否存在
|
||||
|
|
@ -72,6 +71,9 @@ function _M.addSystemUser(jsonData)
|
|||
|
||||
--键值为id产生uuid数据值,增加到json中
|
||||
jsonData.id = helpers.getUuid()
|
||||
--用户密码暂时使用md5进行加密
|
||||
local pwd = jsonData['password']
|
||||
jsonData.password = ngx.encode_md5(pwd)
|
||||
-- 创建一个用户
|
||||
return userModel:create(jsonData)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,9 +3,13 @@
|
|||
--- Created by frankly.
|
||||
--- DateTime: 2025/11/3 18:44
|
||||
---
|
||||
--[[
|
||||
在"ngx_lua"模块的"init_by_lua_file"命令中执行;
|
||||
只在启动nginx时初始化一次。
|
||||
--]]
|
||||
|
||||
print("init application...")
|
||||
|
||||
--初始化,获取系统默认的用户权限,为实现RBAC框架做权限数据准备
|
||||
cjson = require "cjson"
|
||||
local dict_a = ngx.shared.dict_a
|
||||
local v = dict_a:get("abc")
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user