Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Database
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Coscine
backend
libraries
Database
Commits
fc0a1045
Commit
fc0a1045
authored
4 years ago
by
Petar Hristov
Browse files
Options
Downloads
Patches
Plain Diff
Fix: Kleinigkeiten (coscine/issues#1294)
parent
c4f210d1
Branches
Branches containing commit
No related tags found
1 merge request
!120
New: Add the Contact Changing functionality to the database and backend
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Database/Models/ContactChangeModel.cs
+12
-3
12 additions, 3 deletions
src/Database/Models/ContactChangeModel.cs
src/Scaffolding/DataModel/Model.cs
+0
-2
0 additions, 2 deletions
src/Scaffolding/DataModel/Model.cs
with
12 additions
and
5 deletions
src/Database/Models/ContactChangeModel.cs
+
12
−
3
View file @
fc0a1045
...
...
@@ -24,15 +24,21 @@ namespace Coscine.Database.Models
IEnumerable
<
ContactChange
>
emailData
=
GetAllWhere
((
contactChange
)
=>
contactChange
.
UserId
==
userId
);
// Return True if entries for a user exist inside the database table ContactChange. Else return False.
if
(
emailData
.
Count
()
>
0
)
{
return
true
;
}
else
{
return
false
;
}
}
public
ContactChangeObject
NewEmailChangeRequest
(
Guid
userId
,
string
email
)
{
if
(
UserHasEmailsToConfirm
(
userId
))
{
DeleteAllDbEntries
(
userId
);
// <--- REMOVE THIS LINE IF YOU WANT TO KEEP HISTORY OF EMAIL CHANGES.
}
ContactChangeObject
contactChangeObject
=
AddDbEntry
(
userId
,
email
);
// Sending a confirmation email after an addition to the database is handled by the Controller.
return
contactChangeObject
;
...
...
@@ -43,7 +49,9 @@ namespace Coscine.Database.Models
List
<
ContactChangeObject
>
contactChangeObjects
=
new
List
<
ContactChangeObject
>();
IEnumerable
<
ContactChange
>
emailData
=
GetAllWhere
((
contactChange
)
=>
contactChange
.
UserId
==
userId
);
foreach
(
var
entry
in
emailData
)
{
contactChangeObjects
.
Add
(
ToObject
(
entry
));
}
return
contactChangeObjects
;
}
...
...
@@ -72,20 +80,17 @@ namespace Coscine.Database.Models
}
else
{
// EXPIRED
throw
new
Exception
(
"EXPIRED: Token "
+
token
.
ToString
()
+
" has expired."
);
}
}
else
{
// INVALID (null EditDate)
throw
new
ArgumentNullException
(
"INVALID: Value EditDate is NULL for Token "
+
token
.
ToString
()
+
"."
);
}
}
else
{
// INVALID (token-user combination not in Database)
throw
new
MissingFieldException
(
"INVALID: The Token "
+
token
.
ToString
()
+
" is not valid. No entry inside the Database."
);
}
}
...
...
@@ -101,7 +106,9 @@ namespace Coscine.Database.Models
// Token EXPIRED when expirationDateTime = -1 (Expiration is BEFORE Now)
// Token VALID when expirationDateTime = 0 OR = 1 (Expiration IS Now or AFTER Now)
if
(
compareDateTime
<
0
)
{
Delete
(
entry
);
}
}
}
...
...
@@ -109,7 +116,9 @@ namespace Coscine.Database.Models
{
IEnumerable
<
ContactChange
>
emailData
=
GetAllWhere
((
contactChange
)
=>
contactChange
.
UserId
==
userId
);
foreach
(
var
entry
in
emailData
)
{
Delete
(
entry
);
}
}
private
ContactChangeObject
AddDbEntry
(
Guid
userId
,
string
email
)
...
...
This diff is collapsed.
Click to expand it.
src/Scaffolding/DataModel/Model.cs
+
0
−
2
View file @
fc0a1045
...
...
@@ -58,8 +58,6 @@ namespace Coscine.Database.DataModel
{
if
(!
optionsBuilder
.
IsConfigured
)
{
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. See http://go.microsoft.com/fwlink/?LinkId=723263 for guidance on storing connection strings.
optionsBuilder
.
UseSqlServer
(
"Data Source=d-db-d02\\mssql14;Integrated Security=False;User ID=coscineDev;Password=Dev#123;Database=Coscine_hp-admin "
);
}
}
...
...
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