ftp-manager/app/controllers/accounts_controller.rb
Mark Moser 1ba40c965d password reveal toggling
Squashed commit of the following:

commit fde3cc16310062842ccc676a7c33ebfe9b7a3372
Author: Mark Moser <MarkAMoser@gmail.com>
Date:   Sun Sep 11 19:51:32 2016 -0500

    icons

commit f4765d24073cdc7e790e9d6fbb73155ba96ac414
Author: Mark Moser <MarkAMoser@gmail.com>
Date:   Sun Sep 11 19:22:14 2016 -0500

    view toggling

commit 0929b005981a34e46aa0ad6e59d315d5203eed02
Author: Mark Moser <MarkAMoser@gmail.com>
Date:   Sun Sep 11 10:21:03 2016 -0500

    controller xhr

commit 859e1dff28f17feb43f9facc57f887f24e9e8fed
Author: Mark Moser <MarkAMoser@gmail.com>
Date:   Sun Sep 11 09:18:57 2016 -0500

    wip
2016-09-11 19:53:02 -05:00

80 lines
2.0 KiB
Ruby

class AccountsController < ApplicationController
before_action :set_account, only: [:show, :edit, :reveal, :update, :destroy]
# GET /accounts
# GET /accounts.json
def index
@accounts = Account.all
end
# GET /accounts/1
# GET /accounts/1.json
def show
end
# GET /accounts/new
def new
@account = Account.new
end
# GET /accounts/1/edit
def edit
end
def reveal
render json: { hash: @account.password }.to_json
end
# POST /accounts
# POST /accounts.json
def create
@account = Account.new(account_params)
respond_to do |format|
if @account.save
format.html { redirect_to @account, notice: 'Account was successfully created.' }
format.json { render :show, status: :created, location: @account }
else
format.html { render :new }
format.json { render json: @account.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /accounts/1
# PATCH/PUT /accounts/1.json
def update
respond_to do |format|
if @account.update(account_params)
format.html { redirect_to @account, notice: 'Account was successfully updated.' }
format.json { render :show, status: :ok, location: @account }
else
format.html { render :edit }
format.json { render json: @account.errors, status: :unprocessable_entity }
end
end
end
# DELETE /accounts/1
# DELETE /accounts/1.json
def destroy
@account.destroy
respond_to do |format|
format.html { redirect_to accounts_url, notice: 'Account was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_account
@account = Account.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def account_params
params.require(:account).permit(:username, :password, :home, :site)
end
end