diff --git a/frameworks/js/napi/user_auth/src/auth_instance_v9.cpp b/frameworks/js/napi/user_auth/src/auth_instance_v9.cpp index 86073470f..53bb66c19 100644 --- a/frameworks/js/napi/user_auth/src/auth_instance_v9.cpp +++ b/frameworks/js/napi/user_auth/src/auth_instance_v9.cpp @@ -51,8 +51,8 @@ UserAuthResultCode AuthInstanceV9::GetAvailableStatus(napi_env env, napi_callbac IAM_LOGE("napi_get_value_int32 fail:%{public}d", ret); return UserAuthResultCode::GENERAL_ERROR; } - if (!UserAuthNapiHelper::CheckAuthType(type)) { - IAM_LOGE("CheckAuthType fail"); + if (!UserAuthNapiHelper::CheckUserAuthType(type)) { + IAM_LOGE("CheckUserAuthType fail"); return UserAuthResultCode::TYPE_NOT_SUPPORT; } uint32_t level; diff --git a/services/ipc/inc/user_auth_service.h b/services/ipc/inc/user_auth_service.h index 7526ca8f5..e814790f4 100644 --- a/services/ipc/inc/user_auth_service.h +++ b/services/ipc/inc/user_auth_service.h @@ -65,8 +65,6 @@ private: std::shared_ptr GetAuthContextCallback(const AuthParam &authParam, const WidgetParam &widgetParam, sptr &callback); bool CheckAuthTrustLevel(AuthTrustLevel authTrustLevel); - ResultCode CheckNorthPermission(AuthType authType); - ResultCode CheckServicePermission(AuthType authType); bool CheckSingeFaceOrFinger(const std::vector &authType); int32_t CheckAuthWidgetType(const std::vector &authType); int32_t CheckAuthWidgetParam( diff --git a/services/ipc/src/user_auth_service.cpp b/services/ipc/src/user_auth_service.cpp index bb36ccda0..45ab4f635 100644 --- a/services/ipc/src/user_auth_service.cpp +++ b/services/ipc/src/user_auth_service.cpp @@ -128,10 +128,14 @@ bool UserAuthService::CheckAuthTrustLevel(AuthTrustLevel authTrustLevel) int32_t UserAuthService::GetAvailableStatus(int32_t apiVersion, AuthType authType, AuthTrustLevel authTrustLevel) { IAM_LOGI("start"); - ResultCode checkRet = CheckServicePermission(authType); - if (checkRet != SUCCESS) { + if (!IpcCommon::CheckPermission(*this, ACCESS_USER_AUTH_INTERNAL_PERMISSION) && + !IpcCommon::CheckPermission(*this, ACCESS_BIOMETRIC_PERMISSION)) { IAM_LOGE("failed to check permission"); - return checkRet; + return CHECK_PERMISSION_FAILED; + } + if (apiVersion <= API_VERSION_8 && authType == PIN) { + IAM_LOGE("authType not support"); + return TYPE_NOT_SUPPORT; } if (!CheckAuthTrustLevel(authTrustLevel)) { IAM_LOGE("authTrustLevel is not in correct range"); @@ -257,23 +261,6 @@ void UserAuthService::SetProperty(int32_t userId, AuthType authType, const Attri callback->OnSetExecutorPropertyResult(result); } -ResultCode UserAuthService::CheckNorthPermission(AuthType authType) -{ - if (!IpcCommon::CheckPermission(*this, ACCESS_BIOMETRIC_PERMISSION)) { - IAM_LOGE("CheckNorthPermission failed, no permission"); - return CHECK_PERMISSION_FAILED; - } - return SUCCESS; -} - -ResultCode UserAuthService::CheckServicePermission(AuthType authType) -{ - if (IpcCommon::CheckPermission(*this, ACCESS_USER_AUTH_INTERNAL_PERMISSION)) { - return SUCCESS; - } - return CheckNorthPermission(authType); -} - std::shared_ptr UserAuthService::GetAuthContextCallback(const std::vector &challenge, AuthType authType, AuthTrustLevel authTrustLevel, sptr &callback) { @@ -305,10 +292,14 @@ uint64_t UserAuthService::Auth(int32_t apiVersion, const std::vector &c return BAD_CONTEXT_ID; } Attributes extraInfo; - ResultCode checkRet = CheckNorthPermission(authType); - if (checkRet != SUCCESS) { - IAM_LOGE("CheckNorthPermission failed"); - contextCallback->OnResult(checkRet, extraInfo); + if (!IpcCommon::CheckPermission(*this, ACCESS_BIOMETRIC_PERMISSION)) { + IAM_LOGE("failed to check permission"); + contextCallback->OnResult(CHECK_PERMISSION_FAILED, extraInfo); + return BAD_CONTEXT_ID; + } + if (authType == PIN) { + IAM_LOGE("authType not support"); + contextCallback->OnResult(TYPE_NOT_SUPPORT, extraInfo); return BAD_CONTEXT_ID; } int32_t userId;