Class: IpcAuthpipe::Handler::Pre
- Defined in:
- lib/ipcauthpipe/handler/pre.rb
Overview
AUTH command handler performs actual authentication of user’s data. It gets authentication type and parameters from the input stream and responds with FAIL on failure or user data on success
Class Method Summary collapse
Instance Method Summary collapse
-
#split_request(request) ⇒ Object
Splits request into service and username parts, raises ArgumentError if request string is invalid.
-
#user_details(request) ⇒ Object
Finds member by his username and dumps his details, returns FAIL if not member were found.
Methods inherited from Base
Class Method Details
Instance Method Details
#split_request(request) ⇒ Object
Splits request into service and username parts, raises ArgumentError if request string is invalid
16 17 18 19 |
# File 'lib/ipcauthpipe/handler/pre.rb', line 16 def split_request(request) raise ArgumentError, "Invalid PRE request #{request.inspect}" unless /^\. (\w+) (\w+)$/.match( request ) { :service => $~[1], :username => $~[2] } end |
#user_details(request) ⇒ Object
Finds member by his username and dumps his details, returns FAIL if not member were found
22 23 24 25 26 27 |
# File 'lib/ipcauthpipe/handler/pre.rb', line 22 def user_details(request) member = Member.find_by_name(request[:username]) member.create_homedir unless member.nil? # make sure the homedir exists member.nil? ? "FAIL\n" : member.to_authpipe end |