232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
|
# File 'lib/junebug/controllers.rb', line 232
def post
@page_title = "Login/Create Account"
@user = User.find :first, :conditions => ['username = ? AND password = ?', input.username, input.password]
@return_to = input.return_to
if @user
if @user.password == input.password
@state.user = @user
input.return_to.blank? ? redirect(Junebug.startpage) : redirect(input.return_to)
return
else
@notice = 'Authentication failed'
end
else
@user = User.create :username=>input.username, :password=>input.password
if @user.errors.empty?
@state.user = @user
input.return_to.blank? ? redirect(Junebug.startpage) : redirect(input.return_to)
return
else
@notice = @user.errors.full_messages[0]
end
end
render :login
end
|