Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
notifications-bot
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
archives
notifications-bot
Commits
f9ae81bd
Commit
f9ae81bd
authored
5 years ago
by
Jonah Husson
Browse files
Options
Downloads
Patches
Plain Diff
add auth check to nb endpoints
parent
47b993a9
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
notifications/notifications.go
+6
-0
6 additions, 0 deletions
notifications/notifications.go
with
6 additions
and
0 deletions
notifications/notifications.go
+
6
−
0
View file @
f9ae81bd
...
...
@@ -193,6 +193,9 @@ func pollForNotifications(nb *Impl) (strings []string, e error) {
// RegisterForNotifications is called by the client, and adds a user registration to our database
func
(
nb
*
Impl
)
RegisterForNotifications
(
clientToken
[]
byte
,
auth
*
connect
.
Auth
)
error
{
if
!
auth
.
IsAuthenticated
{
return
errors
.
New
(
"Cannot register for notifications: client is not authenticated"
)
}
// Implement this
u
:=
&
storage
.
User
{
Id
:
auth
.
Sender
.
GetId
(),
...
...
@@ -207,6 +210,9 @@ func (nb *Impl) RegisterForNotifications(clientToken []byte, auth *connect.Auth)
// UnregisterForNotifications is called by the client, and removes a user registration from our database
func
(
nb
*
Impl
)
UnregisterForNotifications
(
auth
*
connect
.
Auth
)
error
{
if
!
auth
.
IsAuthenticated
{
return
errors
.
New
(
"Cannot unregister for notifications: client is not authenticated"
)
}
err
:=
nb
.
Storage
.
DeleteUser
(
auth
.
Sender
.
GetId
())
if
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"Failed to unregister user with notifications"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment