当前位置:网站首页>Realize user registration and login
Realize user registration and login
2022-07-03 19:38:00 【Xiao Er Li】
structure request
registration_request.dart
class RegistrationRequest extends BaseRequest {
@override
bool needLogin() {
return false;
}
@override
String path() {
return '/uapi/user/registration';
}
@override
HttpMethod httpMethod() {
return HttpMethod.POST;
}
}
login_request.dart
class LoginRequest extends BaseRequest {
@override
bool needLogin() {
return false;
}
@override
String path() {
return '/uapi/user/login';
}
@override
HttpMethod httpMethod() {
return HttpMethod.POST;
}
}
Package registration 、 Login request
LoginDao.dart
Register for 、 Login interface request encapsulation , Cache the user ID after successful login .
class LoginDao {
static final String BOARDING_PASS = "auth_token";
/// Sign in
static login(String userName, String password) {
return _send(userName, password);
}
// register
static registration(
String userName, String password, String imoocId, String orderId) {
return _send(userName, password, imoocId: imoocId, orderId: orderId);
}
/// Request data interface Return request data
static _send(String userName, String password, {
imoocId, orderId}) async {
// structure request object
BaseRequest request;
if (imoocId != null && orderId != null) {
request = RegistrationRequest();
} else {
request = LoginRequest();
}
// Add request parameters
request
.add('userName', userName)
.add('password', password)
.add('imoocId', imoocId)
.add('orderId', orderId);
// Send network request
var result = await HiNet.getInstance().fire(request);
// Request interface succeeded
if (result['code'] == 0 && result['data'] != null) {
// Cache user ID
HiCache.getInstance().setString(BOARDING_PASS, result['data']);
}
return result;
}
/** * Get the login token */
static getBoardingPass() {
return HiCache.getInstance().get(BOARDING_PASS);
}
}
add to Header
base_request.dart
In the build url Determine whether the interface needs to log in , If necessary, add the user login ID to header.
// If you need to log in , Then add login token to header
if (needLogin()) {
addHeader(LoginDao.BOARDING_PASS, LoginDao.getBoardingPass());
}
Send a request
var result = await LoginDao.registration('jale', '134', '1343', '5509');
var result2 = await LoginDao.login('17600898102', 'muke159346');
边栏推荐
- 05 -- QT OpenGL draw cube uniform
- Zhang Fei hardware 90 day learning notes - personal records on day 2, please see my personal profile / homepage for the complete
- 2022-06-27 网工进阶(十二)IS-IS-开销类型、开销计算、LSP的处理机制、路由撤销、路由渗透
- Buuctf's different flags and simplerev
- Chapter 1: drinking soft drinks, step tariff calculation, step tariff calculation function, personal income tax, solving square root inequality, simplifying solving square root inequality, solving dem
- OSPF - detailed explanation of stub area and full stub area
- Random numbers in a long range, is that right- Random number in long range, is this the way?
- Use unique_ PTR forward declaration? [repetition] - forward declaration with unique_ ptr? [duplicate]
- FBI warning: some people use AI to disguise themselves as others for remote interview
- Flume learning notes
猜你喜欢

Chapter 1: find the algebraic sum of odd factors, find the same decimal sum s (D, n), simplify the same code decimal sum s (D, n), expand the same code decimal sum s (D, n)

2022.2.14 Li Kou - daily question - single element in an ordered array

Summary of composition materials for 2020 high-frequency examination center of educational resources
![Chapter 2: find the number of daffodils based on decomposition, find the number of daffodils based on combination, find the conformal number in [x, y], explore the n-bit conformal number, recursively](/img/c5/0081689817700770f6210d50ec4e1f.png)
Chapter 2: find the number of daffodils based on decomposition, find the number of daffodils based on combination, find the conformal number in [x, y], explore the n-bit conformal number, recursively

第二十章:y= sin(x)/x,漫步坐标系计算,y= sin(x)/x 带廓幅图形,奥运五环,小球滚动与弹跳,流水显示,矩形优化裁剪,r个皇后全控nxn棋盘

01 - QT OpenGL display OpenGL window

Acquisition and transmission of parameters in automatic testing of JMeter interface

04 -- QT OpenGL two sets of shaders draw two triangles
![[free sharing] kotalog diary2022 plan electronic manual ledger](/img/ca/1ffbfcc16e3019261f70274a89c16f.jpg)
[free sharing] kotalog diary2022 plan electronic manual ledger

Free year-end report summary template Welfare Collection
随机推荐
Redis master-slave synchronization, clustering, persistence
PR 2021 quick start tutorial, how to create a new sequence and set parameters?
Ego planner code parsing Bspline_ Optimizer section (2)
During MySQL installation, the download interface is empty, and the components to be downloaded are not displayed. MySQL installer 8.0.28.0 download interface is empty solution
BUUCTF
PR 2021 quick start tutorial, material import and management
Acquisition and transmission of parameters in automatic testing of JMeter interface
2022-06-25 网工进阶(十一)IS-IS-三大表(邻居表、路由表、链路状态数据库表)、LSP、CSNP、PSNP、LSP的同步过程
BOC protected phenylalanine zinc porphyrin (Zn · TAPP Phe BOC) / iron porphyrin (Fe · TAPP Phe BOC) / nickel porphyrin (Ni · TAPP Phe BOC) / manganese porphyrin (Mn · TAPP Phe BOC) Qiyue Keke
[proteus simulation] a simple encrypted electronic password lock designed with 24C04 and 1602LCD
Day11 ---- 我的页面, 用户信息获取修改与频道接口
Floating source code comment (38) parallel job processor
Day_ 18 IO stream system
UE source code analysis: uccharactermovementcomponent - rootmotion
Compared with 4G, what are the advantages of 5g to meet the technical requirements of industry 4.0
Valentine's Day - make an exclusive digital collection for your lover
Octopus online ecological chain tour Atocha protocol received near grant worth $50000
Next spread
TFs and SVN [closed] - TFs vs SVN [closed]
Chapter 1: recursively find the factorial n of n!