-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/delete user integration (#469)
* Add delete user identity server endpoint and delete profile and forms api endpoint * Add adminApi policy to the delete endpoint * Delete only the IDP user * Revert user service changes * revert config * Adding delete account * Using the identity server URL * Fixing browser warning * Update frontend/src/components/DeleteAccount/index.js Co-authored-by: Nicu <[email protected]> * Integrate delete user backend + frontend initial commit of merged commits removed email input * fix cors, moved remove functionality to account endpoint * Update frontend/src/components/DeleteAccount/index.js Co-authored-by: Nicu <[email protected]> * linter fix Co-authored-by: Irinel Nistor <[email protected]> Co-authored-by: Radu Stefanescu <[email protected]> Co-authored-by: Mircea M <[email protected]> Co-authored-by: Nicu <[email protected]> Co-authored-by: ion.dormenco <[email protected]>
- Loading branch information
1 parent
7831ef6
commit fb9cb29
Showing
9 changed files
with
147 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
backend/src/StamAcasa.IdentityServer/Quickstart/Account/DeleteAccountModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
| ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace StamAcasa.IdentityServer.Quickstart.Account | ||
{ | ||
public class DeleteAccountModel | ||
{ | ||
[Required] | ||
public string Email { get; set; } | ||
|
||
[Required] | ||
public string Password { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import axios from "axios"; | ||
import { Constants } from "../config/constants"; | ||
|
||
const api = axios.create({ | ||
baseURL: `${Constants.idpUrl}/account/` | ||
}); | ||
|
||
const AccountApi = { | ||
deleteAccount: (email, password) => api.post("delete", { email, password }) | ||
}; | ||
|
||
export default AccountApi; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import React, { useState } from "react"; | ||
import SidebarLayout from "../SidebarLayout"; | ||
import AccountApi from "../../api/accountApi"; | ||
import "./style.scss"; | ||
import { removeUser, getUser } from "../../api/auth"; | ||
const DeleteAccount = () => { | ||
const [password, setPassword] = useState(""); | ||
const [loading, setLoading] = useState(false); | ||
const [errorDeleting, setErrorDeleting] = useState(false); | ||
|
||
const fieldsFilled = password; | ||
|
||
const updatePassword = event => setPassword(event.target.value); | ||
|
||
const deleteProfile = async () => { | ||
try { | ||
setLoading(true); | ||
const user = await getUser(); | ||
await AccountApi.deleteAccount(user.profile.email, password); | ||
setLoading(false); | ||
await removeUser(); | ||
} catch { | ||
setErrorDeleting(true); | ||
setLoading(false); | ||
} | ||
}; | ||
|
||
const buttonClasses = "button is-danger" + (loading ? " is-loading" : ""); | ||
return ( | ||
<SidebarLayout> | ||
<div> | ||
Contul tău va fi șters. Pentru a putea reutiliza această aplicație va | ||
trebui să îți refaci contul de utilizator. Informațiile pe care le-ai | ||
transmis până acum prin intermediul aplicației vor rămâne stocate în | ||
baza de date. Dacă dorești ca toate informațiile să fie eliminate din | ||
baza de date te rugăm să adresezi această cerere către: | ||
<p>Adresa: Strada Italiană, nr. 22, Sector 2, 020976, București</p> | ||
<p>E-mail: [email protected]</p> | ||
</div> | ||
<form onSubmit={() => {}}> | ||
<div className="field"> | ||
<label className="label">Parola</label> | ||
<input | ||
className="input is-medium" | ||
type="password" | ||
placeholder="Parola" | ||
value={password} | ||
onChange={updatePassword} | ||
/> | ||
</div> | ||
<div className="field"> | ||
<button | ||
className={buttonClasses} | ||
onClick={deleteProfile} | ||
disabled={!fieldsFilled || loading} | ||
> | ||
Șterge cont | ||
</button> | ||
</div> | ||
</form> | ||
<div className="notification is-warning" hidden={!errorDeleting}> | ||
<button className="delete" onClick={() => setErrorDeleting(false)} /> | ||
Încercarea de ștergere a eșuat! | ||
</div> | ||
</SidebarLayout> | ||
); | ||
}; | ||
|
||
export default DeleteAccount; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.notification { | ||
margin-top: 1em; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fb9cb29
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: