mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
onboarding process from anon account to real account
This commit is contained in:
parent
27c060cba9
commit
e17cf877ed
@ -41,7 +41,8 @@ class UsersController < ApplicationController
|
||||
respond_to do |format|
|
||||
if @user.save
|
||||
session[:user] = @user.id
|
||||
format.html { redirect_to dashboard_path, notice: 'You have been logged in to a temporary account that will delete itself (and everything you create with it!) as soon as you log out.' }
|
||||
session[:anon_user] = true
|
||||
format.html { redirect_to dashboard_path }
|
||||
format.json { render json: @user, status: :created }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
@ -57,6 +58,7 @@ class UsersController < ApplicationController
|
||||
|
||||
respond_to do |format|
|
||||
if @user.update_attributes(params[:user])
|
||||
session[:anon_user] = false
|
||||
format.html { redirect_to homepage_path, notice: 'Successfully updated.' }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
|
||||
@ -25,6 +25,17 @@ class User
|
||||
}
|
||||
end
|
||||
|
||||
def content_count
|
||||
[
|
||||
characters.length,
|
||||
equipment.length,
|
||||
languages.length,
|
||||
locations.length,
|
||||
magics.length,
|
||||
universes.length
|
||||
].sum
|
||||
end
|
||||
|
||||
def characters
|
||||
Character.where(user_id: id)
|
||||
end
|
||||
|
||||
9
app/views/layouts/_anon_notice.html.erb
Normal file
9
app/views/layouts/_anon_notice.html.erb
Normal file
@ -0,0 +1,9 @@
|
||||
<% if session[:anon_user] and session[:user] and User.find(session[:user]).content_count > 0 %>
|
||||
|
||||
<div class="navbar" style="padding: 12px; margin-top: -20px; background: #ccffee; border-bottom: 1px solid #bbeeff; text-align: center;">
|
||||
<div class="container">
|
||||
You are currently using an anonymous account. In order to save the brilliant things you have created with it, please <a href="/account">click here</a> to give yourself a username and password.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
@ -75,4 +75,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -8,6 +8,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<%= render 'layouts/navbar' %>
|
||||
<%= render 'layouts/anon_notice' %>
|
||||
<div class="container">
|
||||
<%= render 'layouts/notices' %>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user