module Platformx::AuthHelpers
Public Instance Methods
x_admin_logout!()
click to toggle source
Logs out the amdin
# File lib/platformx/auth.rb, line 19 def x_admin_logout! session[:admin_authorized] = false session.clear end
x_decrypt(str = "")
click to toggle source
Decodes an encoded string
@param str [String] the encoded string
@return [String] decoded string
# File lib/platformx/auth.rb, line 64 def x_decrypt(str = "") str = Base64.urlsafe_decode64(str) #decrypted_value = Encryptor.decrypt(:value => str, :key => '=PeuMX7B4LQ#@jG*s;tYGdF') return str.to_i end
x_encrypt(int = "")
click to toggle source
Encodes a value to a base 64 string.
@note The provided object should respond to `#to_s` to obtain a string representation of the object.
@param int [Object] the value required to be encrypted
@return [String] encoded string
# File lib/platformx/auth.rb, line 53 def x_encrypt(int = "") str = int.to_s #encrypted_value = Encryptor.encrypt(:value => str, :key => "=PeuMX7B4LQ#@jG*s;tYGdF") return Base64.urlsafe_encode64(str) end
x_generate_password(len = "10")
click to toggle source
Generate a random password
@param len [Integer] the length of the password
@return [String] random generated password
# File lib/platformx/auth.rb, line 75 def x_generate_password(len = "10") random_password = Array.new(len).map { (65 + rand(58)).chr }.join return random_password end
x_logout!()
click to toggle source
Logs out the currenly logged in user
# File lib/platformx/auth.rb, line 39 def x_logout! session[:authorized] = false session.clear end