2019-04-05 22:14:20 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# Las piratas son las que activan el Miniloom
|
|
|
|
class PiratasController < ApplicationController
|
2019-04-21 02:25:39 +00:00
|
|
|
# Todo necesita autenticación salvo la creación de cuentas
|
|
|
|
before_action :authenticate!, except: %i[create]
|
2019-04-06 20:41:44 +00:00
|
|
|
# POST /piratas
|
|
|
|
#
|
2019-04-05 22:14:20 +00:00
|
|
|
# Registra una cuenta
|
2019-04-06 20:41:44 +00:00
|
|
|
#
|
|
|
|
# @param pirata [Hash] { pirata: { password: @string, email: @string,
|
|
|
|
# nick: @string } }
|
|
|
|
# @return [Hash] { id: @int, nick: @string, email: @string }
|
2019-04-05 22:14:20 +00:00
|
|
|
def create
|
|
|
|
@pirata = Pirata.new(params
|
|
|
|
.require(:pirata)
|
|
|
|
.permit(:email, :nick, :password))
|
|
|
|
|
|
|
|
return if @pirata.save
|
|
|
|
|
2019-04-20 15:49:31 +00:00
|
|
|
render json: { errors: @pirata.errors.messages },
|
2019-04-05 22:14:20 +00:00
|
|
|
status: :unprocessable_entity
|
|
|
|
end
|
2019-04-21 02:25:39 +00:00
|
|
|
|
|
|
|
# GET /piratas/yo
|
|
|
|
#
|
|
|
|
# Obtener el perfil propio
|
|
|
|
#
|
2020-06-21 00:43:01 +00:00
|
|
|
# @return [Hash] { id: @int, nick: @string, email: @string, telegram_url: @string }
|
2019-04-21 02:25:39 +00:00
|
|
|
def yo
|
|
|
|
@pirata = current_pirata
|
|
|
|
end
|
2019-04-05 22:14:20 +00:00
|
|
|
end
|