Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
Automat
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
冯佳佳
Automat
Commits
8b3f4d93
Commit
8b3f4d93
authored
Jan 19, 2022
by
Aeolus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
9ec762fc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
2 deletions
+4
-2
myapps/automat/api/rent_portal.py
+2
-0
utils/jwt_util.py
+2
-2
No files found.
myapps/automat/api/rent_portal.py
View file @
8b3f4d93
...
@@ -99,6 +99,7 @@ def create_rent():
...
@@ -99,6 +99,7 @@ def create_rent():
rent
.
pay_time
=
datetime
.
datetime
.
now
()
rent
.
pay_time
=
datetime
.
datetime
.
now
()
rent
.
rent_type
=
type
rent
.
rent_type
=
type
rent
.
mch_platform
=
machine
.
mch_platform
rent
.
mch_platform
=
machine
.
mch_platform
rent
.
place_id
=
machine
.
place_id
rent_detail
=
RentDetail
()
rent_detail
=
RentDetail
()
rent_detail
.
rent_no
=
rent_no
rent_detail
.
rent_no
=
rent_no
...
@@ -113,6 +114,7 @@ def create_rent():
...
@@ -113,6 +114,7 @@ def create_rent():
rent_detail
.
production_type_id
=
open_hatch
.
production_type_id
rent_detail
.
production_type_id
=
open_hatch
.
production_type_id
rent_detail
.
production_type_name
=
open_hatch
.
production_type_name
rent_detail
.
production_type_name
=
open_hatch
.
production_type_name
rent_detail
.
price
=
0
rent_detail
.
price
=
0
rent_detail
.
original_price
=
open_hatch
.
original_price
rent_detail
.
total
=
0
rent_detail
.
total
=
0
rent_detail
.
rent_count
=
1
rent_detail
.
rent_count
=
1
rent_detail
.
img
=
open_hatch
.
img
rent_detail
.
img
=
open_hatch
.
img
...
...
utils/jwt_util.py
View file @
8b3f4d93
#!usr/bin/.env python # -*- coding:utf-8 _*- """ @version: author:Aeolus @time: 2021/03/30 @file: jwt_util.py @function: @modify: """ import jwt from flask import current_app def generate_jwt(payload, expiry, secret=None): """ 生成jwt :param payload: dict 载荷 :param expiry: datetime 有效期 :param secret: 密钥 :return: jwt """ _payload = {'exp': expiry} _payload.update(payload) if not secret: secret = current_app.config['SECRET_KEY'] token = jwt.encode(_payload, secret, algorithm='HS256') return token def verify_jwt(token, secret=None): """ 检验jwt :param token: jwt :param secret: 密钥 :return: dict: payload """ if not secret: secret = current_app.config['SECRET_KEY'] try: payload = jwt.decode(token, secret, algorithms=['HS256']) except jwt.PyJWTError: payload = None return payload if __name__ == '__main__': import time from config.env_path_config import env_path from dotenv import load_dotenv load_dotenv(dotenv_path=env_path, verbose=True, override=True) import os SECRET_KEY = os.getenv('SECRET_KEY') token = generate_jwt({"user_id": 1}, time.time() + 6000, SECRET_KEY) # token = generate_jwt({"user_no": 'SK000007'}, time.time() + 6000, SECRET_KEY) print(token) # for i in range(10): # result = verify_jwt(token, 'secret') # print(result) # print(time.time()) # time.sleep(1)
#!usr/bin/.env python # -*- coding:utf-8 _*- """ @version: author:Aeolus @time: 2021/03/30 @file: jwt_util.py @function: @modify: """ import jwt from flask import current_app def generate_jwt(payload, expiry, secret=None): """ 生成jwt :param payload: dict 载荷 :param expiry: datetime 有效期 :param secret: 密钥 :return: jwt """ _payload = {'exp': expiry} _payload.update(payload) if not secret: secret = current_app.config['SECRET_KEY'] token = jwt.encode(_payload, secret, algorithm='HS256') return token def verify_jwt(token, secret=None): """ 检验jwt :param token: jwt :param secret: 密钥 :return: dict: payload """ if not secret: secret = current_app.config['SECRET_KEY'] try: payload = jwt.decode(token, secret, algorithms=['HS256']) except jwt.PyJWTError: payload = None return payload if __name__ == '__main__': import time from config.env_path_config import env_path from dotenv import load_dotenv load_dotenv(dotenv_path=env_path, verbose=True, override=True) import os SECRET_KEY = os.getenv('SECRET_KEY') token = generate_jwt({"user_id": 10}, time.time() + 6000, SECRET_KEY) # token = generate_jwt({"user_no": 'SK000007'}, time.time() + 6000, SECRET_KEY) print(token) # for i in range(10): # result = verify_jwt(token, 'secret') # print(result) # print(time.time()) # time.sleep(1)
\ No newline at end of file
\ No newline at end of file
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment