简体   繁体   English

为系统进行身份验证设计(登录表单)的好习惯是什么?

[英]What is a good practice to make authentification design(login form) for a system

Hi guys currently I am making an employee managment system. 嗨,大家好,目前我正在建立一个员工管理系统。

I have made some forms of the applications like CRUD form of employee ,and stuff. 我已经制作了一些形式的应用程序,如CRUD形式的员工和东西。 I also have implemented the login form , with users from database but I am having a problem to design the database correctly. 我也已经实现了登录表单,来自数据库的用户,但我正确地设计数据库有问题。 I want each time that I add an employee from Employee CRUD form , to be added as a user that can login into the system.. 我想每次从Employee CRUD表单添加一个员工,作为可以登录系统的用户添加..
Currently I am adding users manually in the database, but I dont want this , because the users will be from 3 categories , Employee,Admin,And manager.. 目前我在数据库中手动添加用户,但我不想这样,因为用户将来自3个类别,员工,管理员和经理..
I am using JPA for database.Below I will show you a photo of the database schema. 我正在使用JPA for database.Below我将向您展示数据库模式的照片。

DB SCHEMA

What will be a good practice so each time I add an employee to be added as a USER that can login into the system, 什么是一个好的做法所以每次我添加一个员工作为可以登录系统的用户,

Thank you for every answer, and for your time.. 谢谢你的每一个答案,以及你的时间..

The easiest solution would be to have booleans inside your employee table, (isUser, isManager ...). 最简单的解决方案是在employee表中包含布尔值(isUser,isManager ......)。 This is good if you can have one or more roles and if you don't need more informations (a user is just an employee with a boolean checked). 如果您可以拥有一个或多个角色并且不需要更多信息(用户只是一个选中了布尔值的员工),那么这很好。

-- -

If you need more informations about your roles, you can link your employee table to an other table with the fields you need. 如果您需要有关角色的更多信息,可以将employee表链接到包含所需字段的其他表。

For exemple between an employee and a user, add a foreign key inside Employee (userID) and a table named user with the fields you need. 例如,在员工和用户之间,在Employee(userID)和名为user的表中添加您需要的字段。 For example : 例如 :

userID, password, lastConnectionDate ... userID,密码,lastConnectionDate ...

-- -

An other way would be to have a table "roles" and a table "employe". 另一种方法是拥有表“角色”和表“雇员”。 The idea is to add an other table "employeeRoles" that have 3 keys : 想法是添加另一个有“3个键”的表“employeeRoles”:

IDEmployeeRoles, IDEmployee, IDRole IDEmployeeRoles,IDEmployee,IDRole

Like that you will be able to link many employees with many roles. 就像那样,您将能够将许多员工与许多角色联系起来。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM