40 lines
811 B
Ruby
40 lines
811 B
Ruby
require 'sqlite3'
|
|
|
|
def get_user_id(username)
|
|
db = SQLite3::Database.new('./database/auth.db')
|
|
|
|
user_id = db.get_first_value('
|
|
SELECT id
|
|
FROM users U
|
|
WHERE U.username = ?
|
|
|
|
', [username])
|
|
|
|
return user_id
|
|
end
|
|
|
|
def get_user_hashed_password(user_id)
|
|
db = SQLite3::Database.new('./database/auth.db')
|
|
|
|
password_hash = db.get_first_value('
|
|
SELECT hashed_password
|
|
FROM users U
|
|
WHERE U.id = ?
|
|
|
|
', [user_id])
|
|
|
|
return password_hash
|
|
end
|
|
|
|
def get_user_salt(user_id)
|
|
db = SQLite3::Database.new('./database/auth.db')
|
|
|
|
salt = db.get_first_value('
|
|
SELECT salt
|
|
FROM users U
|
|
WHERE U.id = ?
|
|
|
|
', [user_id])
|
|
|
|
return salt
|
|
end |