class SessionsController < ApplicationController
require 'util_functions'
def new
end
def create
p4 = Utils::get_p4
server = Utils::get_server
user = params[:session][:name]
password = params[:session][:password]
output = `echo #{password} | #{p4} -p #{server} -u #{user} login -p 2>&1`
regex = /\AEnter password: .?[A-Z0-9]+.?\z/m
failed_connection = /\A.*Connect to server failed.*\z/m
if output =~ regex
sign_in
flash[:success] = "Login successful"
redirect_to webhooks_path
elsif output =~ failed_connection
flash.now[:error] = "Perforce server could not be reached."
render :new
else
flash.now[:error] = "Invalid login information."
render :new
end
end
def destroy
sign_out
redirect_to signin_url
end
end
# |
Change |
User |
Description |
Committed |
|
#1
|
10132 |
jim_brower |
Moved sendrequest.rb and added webhook-wrapper |
|
|