tm_lyn 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +8 -0
- data/app/assets/stylesheets/tm_lyn/application.css +15 -0
- data/app/channels/application_cable/connection.rb +16 -0
- data/app/controllers/concerns/authentication.rb +52 -0
- data/app/controllers/passwords_controller.rb +33 -0
- data/app/controllers/sessions_controller.rb +21 -0
- data/app/controllers/tm_lyn/application_controller.rb +4 -0
- data/app/controllers/tm_lyn/categories_controller.rb +34 -0
- data/app/helpers/tm_lyn/application_helper.rb +4 -0
- data/app/helpers/tm_lyn/categories_helper.rb +4 -0
- data/app/jobs/tm_lyn/application_job.rb +4 -0
- data/app/mailers/passwords_mailer.rb +6 -0
- data/app/mailers/tm_lyn/application_mailer.rb +6 -0
- data/app/models/current.rb +4 -0
- data/app/models/session.rb +3 -0
- data/app/models/tm_lyn/application_record.rb +5 -0
- data/app/models/tm_lyn/category.rb +6 -0
- data/app/models/user.rb +6 -0
- data/app/views/layouts/tm_lyn/application.html.erb +17 -0
- data/app/views/passwords/edit.html.erb +9 -0
- data/app/views/passwords/new.html.erb +8 -0
- data/app/views/passwords_mailer/reset.html.erb +4 -0
- data/app/views/passwords_mailer/reset.text.erb +2 -0
- data/app/views/sessions/new.html.erb +11 -0
- data/app/views/tm_lyn/categories/edit.html.erb +1 -0
- data/app/views/tm_lyn/categories/index.html.erb +1 -0
- data/app/views/tm_lyn/categories/new.html.erb +1 -0
- data/config/routes.rb +3 -0
- data/db/migrate/20241219121331_create_tm_lyn_categories.rb +10 -0
- data/lib/tasks/tm_lyn_tasks.rake +4 -0
- data/lib/tm_lyn/engine.rb +5 -0
- data/lib/tm_lyn/version.rb +3 -0
- data/lib/tm_lyn.rb +6 -0
- metadata +95 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4d038457b12d2cabdbad167fbd14afc7716e0c2829dd45d6d328f6bfca7e31d1
|
4
|
+
data.tar.gz: 41e7ffda4e85fa454fe320a6db38c40c69d94f177c04290f80de13684b6e8843
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8811bc487a0c49b819b2ba543733539c9ff3c840731de3591ebc57aedf947ab639bfdabb8ffa75811623e86e3d8c7966ffc19c8443b0b69178a6df18fc7d7920
|
7
|
+
data.tar.gz: 6e99a2c4158e4e1f3a403f115dda0376d2ebbe95f64684dee3ad64abfa622da28758f2270ad9c08fe1861cdc95d4cf884cda1e5426bfb833fa43a3068916798b
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright Lynelle0503
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# TmLyn
|
2
|
+
Short description and motivation.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
How to use my plugin.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem "tm_lyn"
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
```bash
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
```bash
|
21
|
+
$ gem install tm_lyn
|
22
|
+
```
|
23
|
+
|
24
|
+
## Contributing
|
25
|
+
Contribution directions go here.
|
26
|
+
|
27
|
+
## License
|
28
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module ApplicationCable
|
2
|
+
class Connection < ActionCable::Connection::Base
|
3
|
+
identified_by :current_user
|
4
|
+
|
5
|
+
def connect
|
6
|
+
set_current_user || reject_unauthorized_connection
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
def set_current_user
|
11
|
+
if session = Session.find_by(id: cookies.signed[:session_id])
|
12
|
+
self.current_user = session.user
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Authentication
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
before_action :require_authentication
|
6
|
+
helper_method :authenticated?
|
7
|
+
end
|
8
|
+
|
9
|
+
class_methods do
|
10
|
+
def allow_unauthenticated_access(**options)
|
11
|
+
skip_before_action :require_authentication, **options
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
def authenticated?
|
17
|
+
resume_session
|
18
|
+
end
|
19
|
+
|
20
|
+
def require_authentication
|
21
|
+
resume_session || request_authentication
|
22
|
+
end
|
23
|
+
|
24
|
+
def resume_session
|
25
|
+
Current.session ||= find_session_by_cookie
|
26
|
+
end
|
27
|
+
|
28
|
+
def find_session_by_cookie
|
29
|
+
Session.find_by(id: cookies.signed[:session_id]) if cookies.signed[:session_id]
|
30
|
+
end
|
31
|
+
|
32
|
+
def request_authentication
|
33
|
+
session[:return_to_after_authenticating] = request.url
|
34
|
+
redirect_to new_session_path
|
35
|
+
end
|
36
|
+
|
37
|
+
def after_authentication_url
|
38
|
+
session.delete(:return_to_after_authenticating) || root_url
|
39
|
+
end
|
40
|
+
|
41
|
+
def start_new_session_for(user)
|
42
|
+
user.sessions.create!(user_agent: request.user_agent, ip_address: request.remote_ip).tap do |session|
|
43
|
+
Current.session = session
|
44
|
+
cookies.signed.permanent[:session_id] = { value: session.id, httponly: true, same_site: :lax }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def terminate_session
|
49
|
+
Current.session.destroy
|
50
|
+
cookies.delete(:session_id)
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class PasswordsController < ApplicationController
|
2
|
+
allow_unauthenticated_access
|
3
|
+
before_action :set_user_by_token, only: %i[ edit update ]
|
4
|
+
|
5
|
+
def new
|
6
|
+
end
|
7
|
+
|
8
|
+
def create
|
9
|
+
if user = User.find_by(email_address: params[:email_address])
|
10
|
+
PasswordsMailer.reset(user).deliver_later
|
11
|
+
end
|
12
|
+
|
13
|
+
redirect_to new_session_path, notice: "Password reset instructions sent (if user with that email address exists)."
|
14
|
+
end
|
15
|
+
|
16
|
+
def edit
|
17
|
+
end
|
18
|
+
|
19
|
+
def update
|
20
|
+
if @user.update(params.permit(:password, :password_confirmation))
|
21
|
+
redirect_to new_session_path, notice: "Password has been reset."
|
22
|
+
else
|
23
|
+
redirect_to edit_password_path(params[:token]), alert: "Passwords did not match."
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
def set_user_by_token
|
29
|
+
@user = User.find_by_password_reset_token!(params[:token])
|
30
|
+
rescue ActiveSupport::MessageVerifier::InvalidSignature
|
31
|
+
redirect_to new_password_path, alert: "Password reset link is invalid or has expired."
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class SessionsController < ApplicationController
|
2
|
+
allow_unauthenticated_access only: %i[ new create ]
|
3
|
+
rate_limit to: 10, within: 3.minutes, only: :create, with: -> { redirect_to new_session_url, alert: "Try again later." }
|
4
|
+
|
5
|
+
def new
|
6
|
+
end
|
7
|
+
|
8
|
+
def create
|
9
|
+
if user = User.authenticate_by(params.permit(:email_address, :password))
|
10
|
+
start_new_session_for user
|
11
|
+
redirect_to after_authentication_url
|
12
|
+
else
|
13
|
+
redirect_to new_session_path, alert: "Try another email address or password."
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def destroy
|
18
|
+
terminate_session
|
19
|
+
redirect_to new_session_path
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module TmLyn
|
2
|
+
class CategoriesController < ApplicationController
|
3
|
+
def index
|
4
|
+
@cats = Category.all
|
5
|
+
end
|
6
|
+
def new
|
7
|
+
@cat = Category.new
|
8
|
+
end
|
9
|
+
def create
|
10
|
+
@cat = Category.new(cat_params)
|
11
|
+
if @cat.save
|
12
|
+
redirect_to categories_path, notice:"Category created"
|
13
|
+
else
|
14
|
+
render :new, status: :unprocessable_entity
|
15
|
+
end
|
16
|
+
end
|
17
|
+
def edit
|
18
|
+
@cat = Category.find(params[:id])
|
19
|
+
end
|
20
|
+
def update
|
21
|
+
@cat = Category.find(params[:id])
|
22
|
+
if @cat.update(cat_params)
|
23
|
+
redirect_to categories_path, notice:"Category updated successfully"
|
24
|
+
else
|
25
|
+
render :edit
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
def cat_params
|
31
|
+
params.require(:category).permit(:name)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/app/models/user.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Tm lyn</title>
|
5
|
+
<%= csrf_meta_tags %>
|
6
|
+
<%= csp_meta_tag %>
|
7
|
+
|
8
|
+
<%= yield :head %>
|
9
|
+
|
10
|
+
<%= stylesheet_link_tag "tm_lyn/application", media: "all" %>
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
This is the TMLyn Plugin page
|
14
|
+
<%= yield %>
|
15
|
+
|
16
|
+
</body>
|
17
|
+
</html>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<h1>Update your password</h1>
|
2
|
+
|
3
|
+
<%= tag.div(flash[:alert], style: "color:red") if flash[:alert] %>
|
4
|
+
|
5
|
+
<%= form_with url: password_path(params[:token]), method: :put do |form| %>
|
6
|
+
<%= form.password_field :password, required: true, autocomplete: "new-password", placeholder: "Enter new password", maxlength: 72 %><br>
|
7
|
+
<%= form.password_field :password_confirmation, required: true, autocomplete: "new-password", placeholder: "Repeat new password", maxlength: 72 %><br>
|
8
|
+
<%= form.submit "Save" %>
|
9
|
+
<% end %>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<h1>Forgot your password?</h1>
|
2
|
+
|
3
|
+
<%= tag.div(flash[:alert], style: "color:red") if flash[:alert] %>
|
4
|
+
|
5
|
+
<%= form_with url: passwords_path do |form| %>
|
6
|
+
<%= form.email_field :email_address, required: true, autofocus: true, autocomplete: "username", placeholder: "Enter your email address", value: params[:email_address] %><br>
|
7
|
+
<%= form.submit "Email reset instructions" %>
|
8
|
+
<% end %>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<%= tag.div(flash[:alert], style: "color:red") if flash[:alert] %>
|
2
|
+
<%= tag.div(flash[:notice], style: "color:green") if flash[:notice] %>
|
3
|
+
|
4
|
+
<%= form_with url: session_path do |form| %>
|
5
|
+
<%= form.email_field :email_address, required: true, autofocus: true, autocomplete: "username", placeholder: "Enter your email address", value: params[:email_address] %><br>
|
6
|
+
<%= form.password_field :password, required: true, autocomplete: "current-password", placeholder: "Enter your password", maxlength: 72 %><br>
|
7
|
+
<%= form.submit "Sign in" %>
|
8
|
+
<% end %>
|
9
|
+
<br>
|
10
|
+
|
11
|
+
<%= link_to "Forgot password?", new_password_path %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<h1>Cat - edit</h1>
|
@@ -0,0 +1 @@
|
|
1
|
+
<h1>Cat - index</h1>
|
@@ -0,0 +1 @@
|
|
1
|
+
<h1>Cat - new</h1>
|
data/config/routes.rb
ADDED
data/lib/tm_lyn.rb
ADDED
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tm_lyn
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Lynelle0503
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-12-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 8.0.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 8.0.1
|
27
|
+
description: Created by lynferns - trial 1
|
28
|
+
email:
|
29
|
+
- 37027090+Lynelle0503@users.noreply.github.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- MIT-LICENSE
|
35
|
+
- README.md
|
36
|
+
- Rakefile
|
37
|
+
- app/assets/stylesheets/tm_lyn/application.css
|
38
|
+
- app/channels/application_cable/connection.rb
|
39
|
+
- app/controllers/concerns/authentication.rb
|
40
|
+
- app/controllers/passwords_controller.rb
|
41
|
+
- app/controllers/sessions_controller.rb
|
42
|
+
- app/controllers/tm_lyn/application_controller.rb
|
43
|
+
- app/controllers/tm_lyn/categories_controller.rb
|
44
|
+
- app/helpers/tm_lyn/application_helper.rb
|
45
|
+
- app/helpers/tm_lyn/categories_helper.rb
|
46
|
+
- app/jobs/tm_lyn/application_job.rb
|
47
|
+
- app/mailers/passwords_mailer.rb
|
48
|
+
- app/mailers/tm_lyn/application_mailer.rb
|
49
|
+
- app/models/current.rb
|
50
|
+
- app/models/session.rb
|
51
|
+
- app/models/tm_lyn/application_record.rb
|
52
|
+
- app/models/tm_lyn/category.rb
|
53
|
+
- app/models/user.rb
|
54
|
+
- app/views/layouts/tm_lyn/application.html.erb
|
55
|
+
- app/views/passwords/edit.html.erb
|
56
|
+
- app/views/passwords/new.html.erb
|
57
|
+
- app/views/passwords_mailer/reset.html.erb
|
58
|
+
- app/views/passwords_mailer/reset.text.erb
|
59
|
+
- app/views/sessions/new.html.erb
|
60
|
+
- app/views/tm_lyn/categories/edit.html.erb
|
61
|
+
- app/views/tm_lyn/categories/index.html.erb
|
62
|
+
- app/views/tm_lyn/categories/new.html.erb
|
63
|
+
- config/routes.rb
|
64
|
+
- db/migrate/20241219121331_create_tm_lyn_categories.rb
|
65
|
+
- lib/tasks/tm_lyn_tasks.rake
|
66
|
+
- lib/tm_lyn.rb
|
67
|
+
- lib/tm_lyn/engine.rb
|
68
|
+
- lib/tm_lyn/version.rb
|
69
|
+
homepage: https://github.com/Lynelle0503/RoRTaskManagement
|
70
|
+
licenses:
|
71
|
+
- MIT
|
72
|
+
metadata:
|
73
|
+
allowed_push_host: https://rubygems.org
|
74
|
+
homepage_uri: https://github.com/Lynelle0503/RoRTaskManagement
|
75
|
+
source_code_uri: https://github.com/Lynelle0503/RoRTaskManagement
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubygems_version: 3.5.23
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: Task Management Plugin
|
95
|
+
test_files: []
|