roysathome.net/auth/database_queries.rb

40 lines
811 B
Ruby
Raw Normal View History

2023-12-11 20:56:09 +00:00
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