mirror of
https://github.com/foss42/apidash.git
synced 2025-12-04 20:13:56 +08:00
feat: add environment variable substitution support for auth models
This commit is contained in:
@@ -20,17 +20,16 @@ class ApiKeyAuthFields extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ApiKeyAuthFieldsState extends State<ApiKeyAuthFields> {
|
||||
late TextEditingController _keyController;
|
||||
late TextEditingController _nameController;
|
||||
late String _key;
|
||||
late String _name;
|
||||
late String _addKeyTo;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final apiAuth = widget.authData?.apikey;
|
||||
_keyController = TextEditingController(text: apiAuth?.key ?? '');
|
||||
_nameController =
|
||||
TextEditingController(text: apiAuth?.name ?? kApiKeyHeaderName);
|
||||
_key = apiAuth?.key ?? '';
|
||||
_name = apiAuth?.name ?? kApiKeyHeaderName;
|
||||
_addKeyTo = apiAuth?.location ?? kAddToDefaultLocation;
|
||||
}
|
||||
|
||||
@@ -66,20 +65,26 @@ class _ApiKeyAuthFieldsState extends State<ApiKeyAuthFields> {
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
AuthTextField(
|
||||
EnvAuthField(
|
||||
readOnly: widget.readOnly,
|
||||
controller: _nameController,
|
||||
hintText: kHintTextFieldName,
|
||||
onChanged: (value) => _updateApiKeyAuth(),
|
||||
initialValue: widget.authData?.apikey?.name,
|
||||
onChanged: (value) {
|
||||
_name = value;
|
||||
_updateApiKeyAuth();
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
AuthTextField(
|
||||
EnvAuthField(
|
||||
readOnly: widget.readOnly,
|
||||
controller: _keyController,
|
||||
title: kLabelApiKey,
|
||||
hintText: kHintTextKey,
|
||||
isObscureText: true,
|
||||
onChanged: (value) => _updateApiKeyAuth(),
|
||||
initialValue: widget.authData?.apikey?.key,
|
||||
onChanged: (value) {
|
||||
_key = value;
|
||||
_updateApiKeyAuth();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -87,8 +92,8 @@ class _ApiKeyAuthFieldsState extends State<ApiKeyAuthFields> {
|
||||
|
||||
void _updateApiKeyAuth() {
|
||||
final apiKey = AuthApiKeyModel(
|
||||
key: _keyController.text.trim(),
|
||||
name: _nameController.text.trim(),
|
||||
key: _key.trim(),
|
||||
name: _name.trim(),
|
||||
location: _addKeyTo,
|
||||
);
|
||||
widget.updateAuth?.call(widget.authData?.copyWith(
|
||||
|
||||
Reference in New Issue
Block a user