loginByPhoneCode static method
Future<AuthResult>
loginByPhoneCode(
- String phone,
- String code, {
- String? phoneCountryCode,
- AuthRequest? authData,
login by phone number and an SMS verification code.
Implementation
static Future<AuthResult> loginByPhoneCode(String phone, String code,
{String? phoneCountryCode, AuthRequest? authData}) async {
Map map = {};
map.putIfAbsent('phone', () => phone);
map.putIfAbsent('code', () => code);
if (phoneCountryCode != null) {
map.putIfAbsent('phoneCountryCode', () => phoneCountryCode);
}
final Result result =
await post('/api/v2/login/phone-code', jsonEncode(map));
AuthResult authResult = AuthResult(result);
authResult.user = await createUser(result);
if (authData == null) {
return authResult;
} else {
if (authResult.code == 200) {
authData.token = authResult.user?.token ?? "";
return OIDCClient.authByToken(authData.token, authData);
} else {
return authResult;
}
}
}