mirror of https://github.com/tp4a/teleport
try to use Enum type.
parent
a43f7b0f35
commit
66bed4d53e
|
@ -1,5 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from enum import IntEnum, unique
|
||||
|
||||
TP_LOGIN_AUTH_SYS_DEFAULT = 0 # 系统默认(根据系统配置进行)
|
||||
TP_LOGIN_AUTH_USERNAME_PASSWORD = 0x0001 # 用户名+密码
|
||||
TP_LOGIN_AUTH_USERNAME_PASSWORD_CAPTCHA = 0x0002 # 用户名+密码+验证码
|
||||
|
@ -9,6 +11,13 @@ TP_LOGIN_AUTH_USERNAME_PASSWORD_OATH = 0x0008 # 用户名+密码+OATH
|
|||
APP_MODE_NORMAL = 1
|
||||
APP_MODE_MAINTENANCE = 2
|
||||
|
||||
|
||||
@unique
|
||||
class TpAppMode(IntEnum):
|
||||
NORMAL = 1
|
||||
MAINTENANCE = 2
|
||||
|
||||
|
||||
# ==========================================================================
|
||||
# 用户类型
|
||||
# ==========================================================================
|
||||
|
@ -16,6 +25,14 @@ TP_USER_TYPE_NONE = 0
|
|||
TP_USER_TYPE_LOCAL = 1
|
||||
TP_USER_TYPE_LDAP = 2
|
||||
|
||||
|
||||
@unique
|
||||
class TpUserType(IntEnum):
|
||||
NONE = 0
|
||||
LOCAL = 1
|
||||
LDAP = 2
|
||||
|
||||
|
||||
# ==========================================================================
|
||||
# 远程主机账号认证方式
|
||||
# ==========================================================================
|
||||
|
|
|
@ -97,7 +97,7 @@ def login(handler, username, password=None, oath_code=None, check_bind_oath=Fals
|
|||
|
||||
err_msg = ''
|
||||
if password is not None:
|
||||
if user_info['type'] == TP_USER_TYPE_LOCAL:
|
||||
if user_info['type'] == TpUserType.LOCAL:
|
||||
# 如果系统配置了密码有效期,则检查用户的密码是否失效
|
||||
if sys_cfg.password.timeout != 0:
|
||||
_time_now = tp_timestamp_sec()
|
||||
|
|
Loading…
Reference in New Issue