Skip to content

Commit 7e1b8c3

Browse files
committed
Fix script cli auth
1 parent 1d883d5 commit 7e1b8c3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

openc3/lib/openc3/utilities/authentication.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,15 @@ class OpenC3AuthenticationRetryableError < OpenC3AuthenticationError; end
3333
# OpenC3 COSMOS Core authentication code
3434
class OpenC3Authentication
3535
def initialize()
36-
@token = ENV['OPENC3_API_PASSWORD']
37-
if @token.nil?
36+
password = ENV['OPENC3_API_PASSWORD']
37+
if password.nil?
3838
raise OpenC3AuthenticationError, "Authentication requires environment variable OPENC3_API_PASSWORD"
3939
end
40+
if OpenC3::AuthModel.verify_password(password)
41+
@token = OpenC3::AuthModel.generate_session()
42+
else
43+
raise OpenC3AuthenticationError, "Password is invalid"
44+
end
4045
end
4146

4247
# Load the token from the environment

0 commit comments

Comments
 (0)