Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
Add set_password func
Browse files Browse the repository at this point in the history
  • Loading branch information
Genki Sugawara committed Nov 2, 2015
1 parent bcd4eab commit aec3716
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/gratan/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,25 @@ def identify(user, host, identifier)
]

update(sql)

if (identifier || '').empty?
set_password(user, host, identifier)
end
end

def set_password(user, host, password, options = {})
password ||= ''

unless options[:hash]
password = "PASSWORD('#{escape(password)}')"
end

sql = 'SET PASSWORD FOR %s = %s' % [
quote_user(user, host),
password,
]

update(sql)
end

def set_require(user, host, required)
Expand Down

0 comments on commit aec3716

Please sign in to comment.