Skip to content

Commit e9bb698

Browse files
committed
refactor(check-password): ensure that defaultDomain is optional
1 parent b53a3ea commit e9bb698

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

src/unix/kerberos_unix.cc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,15 @@ NAN_METHOD(CheckPassword) {
232232
std::string username(*Nan::Utf8String(info[0]));
233233
std::string password(*Nan::Utf8String(info[1]));
234234
std::string service(*Nan::Utf8String(info[2]));
235-
std::string defaultRealm(*Nan::Utf8String(info[3]));
236-
Nan::Callback* callback = new Nan::Callback(Nan::To<v8::Function>(info[4]).ToLocalChecked());
235+
236+
std::string defaultRealm;
237+
Nan::Callback* callback;
238+
if (info[3]->IsFunction()) {
239+
callback = new Nan::Callback(Nan::To<v8::Function>(info[3]).ToLocalChecked());
240+
} else {
241+
defaultRealm = *Nan::Utf8String(info[3]);
242+
callback = new Nan::Callback(Nan::To<v8::Function>(info[4]).ToLocalChecked());
243+
}
237244

238245
KerberosWorker::Run(callback, "kerberos:CheckPassword", [=](KerberosWorker::SetOnFinishedHandler onFinished) {
239246
std::shared_ptr<gss_result> result(authenticate_user_krb5pwd(

src/win32/kerberos_win32.cc

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -173,23 +173,13 @@ NAN_METHOD(InitializeClient) {
173173
}
174174

175175
NAN_METHOD(InitializeServer) {
176-
std::string service(*Nan::Utf8String(info[0]));
177-
Nan::Callback* callback = new Nan::Callback(Nan::To<v8::Function>(info[1]).ToLocalChecked());
178176
Nan::ThrowError("`initializeServer` is not implemented yet for windows");
179177
}
180178

181179
NAN_METHOD(PrincipalDetails) {
182-
std::string service(*Nan::Utf8String(info[0]));
183-
std::string hostname(*Nan::Utf8String(info[1]));
184-
Nan::Callback* callback = new Nan::Callback(Nan::To<v8::Function>(info[2]).ToLocalChecked());
185180
Nan::ThrowError("`principalDetails` is not implemented yet for windows");
186181
}
187182

188183
NAN_METHOD(CheckPassword) {
189-
std::string username(*Nan::Utf8String(info[0]));
190-
std::string password(*Nan::Utf8String(info[1]));
191-
std::string service(*Nan::Utf8String(info[2]));
192-
std::string defaultRealm(*Nan::Utf8String(info[3]));
193-
Nan::Callback* callback = new Nan::Callback(Nan::To<v8::Function>(info[4]).ToLocalChecked());
194184
Nan::ThrowError("`checkPassword` is not implemented yet for windows");
195185
}

0 commit comments

Comments
 (0)