package Ġua . better dating . backend . handlers Ċ Ċ import Ġkotlinx . coroutines . reactive . await First OrNull Ċ import Ġorg . springframework . security . core . Authentication Ċ import Ġorg . springframework . security . crypto . password . Password Encoder Ċ import Ġorg . springframework . security . web . server . Web Filter Exchange Ċ import Ġorg . springframework . security . web . server . authentication . logout . Delegating Server Logout Handler Ċ import Ġorg . springframework . transaction . reactive . Transactional Operator Ċ import Ġorg . springframework . transaction . reactive . execute And Await Ċ import Ġorg . springframework . web . reactive . function . server . Server Request Ċ import Ġorg . springframework . web . reactive . function . server . Server Response Ċ import Ġorg . springframework . web . reactive . function . server . await Body Ċ import Ġorg . springframework . web . reactive . function . server . await Principal Ċ import Ġreactor . core . publisher . Mono Ċ import Ġua . better dating . backend .* Ċ import Ġua . better dating . backend . data .* Ċ import Ġua . better dating . backend . utils . ok Empty JsonObject Ċ import Ġjava . util .* Ċ Ċ class ĠProfile Removal Handler ( ĊĠĠĠ Ġprivate Ġval Ġemail Repository : ĠEmail Repository , ĊĠĠĠ Ġprivate Ġval Ġaccepted Terms Repository : ĠAccept ed Terms Repository , ĊĠĠĠ Ġprivate Ġval Ġprofile Info Repository : ĠProfile Info Repository , ĊĠĠĠ Ġprivate Ġval Ġheight Repository : ĠHeight Repository , ĊĠĠĠ Ġprivate Ġval Ġweight Repository : ĠWeight Repository , ĊĠĠĠ Ġprivate Ġval Ġactivity Repository : ĠActivity Repository , ĊĠĠĠ Ġprivate Ġval Ġprofile Evaluation Repository : ĠProfile Evaluation Repository , ĊĠĠĠ Ġprivate Ġval Ġexp iring Token Repository : ĠExp iring Token Repository , ĊĠĠĠ Ġprivate Ġval Ġuser Role Repository : ĠUser Role Repository , ĊĠĠĠ Ġprivate Ġval Ġhistory Repository : ĠHistory Repository , ĊĠĠĠ Ġprivate Ġval Ġd ating Profile Info Repository : ĠD ating Profile Info Repository , ĊĠĠĠ Ġprivate Ġval Ġuser Pop ulated Local ity Repository : ĠUser Pop ulated Local ity Repository , ĊĠĠĠ Ġprivate Ġval Ġuser Language Repository : ĠUser Language Repository , ĊĠĠĠ Ġprivate Ġval Ġuser Interest Repository : ĠUser Interest Repository , ĊĠĠĠ Ġprivate Ġval Ġuser Personal Quality Repository : ĠUser Personal Quality Repository , ĊĠĠĠ Ġprivate Ġval Ġpairs Repository : ĠPair s Repository , ĊĠĠĠ Ġprivate Ġval Ġlogin Information Repository : ĠLogin Information Repository , ĊĠĠĠ Ġprivate Ġval Ġpair Lock Repository : ĠPair Lock Repository , ĊĠĠĠ Ġprivate Ġval Ġdates Repository : ĠD ates Repository , ĊĠĠĠ Ġprivate Ġval Ġcheck In Repository : ĠCheck In Repository , ĊĠĠĠ Ġprivate Ġval Ġdecision Repository : ĠPair Decision Repository , ĊĠĠĠ Ġprivate Ġval Ġprofile Impro vement Repository : ĠProfile Impro vement Repository , ĊĠĠĠ Ġprivate Ġval Ġprofile Cred ibility Repository : ĠProfile Cred ibility Repository , ĊĠĠĠ Ġprivate Ġval Ġlogout Handler : ĠDeleg ating Server Logout Handler , ĊĠĠĠ Ġprivate Ġval Ġpassword Encoder : ĠPassword Encoder , ĊĠĠĠ Ġprivate Ġval Ġtransaction al Operator : ĠTransaction al Operator , ĊĠĠĠ Ġprivate Ġval Ġfre emark er Mail Sender : ĠF reem ark er Mail Sender ĊĠĠĠ Ġ) Ġ{ ĊĠĠĠ Ġsuspend Ġfun Ġrequest Removal ( request : ĠServer Request ): ĠServer Response Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġprofile Ġ= ĠcurrentUser Email ( email Repository , Ġrequest ) ĊĠĠĠĠĠĠĠ Ġval Ġsubject Ġ= Ġ" ÐĹ Ð°Ð¿ ÑĢÐ¾Ñģ ĠÐ½Ð° ĠÑĥ Ð´Ð°Ð» ÐµÐ½Ð¸Ðµ ĠÐ¿ÑĢÐ¾ ÑĦ Ð¸ Ð»Ñı ĠÐ½Ð° ĠÑģ Ð°Ð¹ ÑĤÐµ ĠÑģÐ¼ Ð¾ÑĤ ÑĢÐ¸ Ð½Ñĭ . Ñĥ Ðº ÑĢ Ġ& ĠÑģÐ¼ Ð¾ÑĤ ÑĢÐ¸ Ð½Ñĭ . ÑĢÑĥ Ñģ " ĊĠĠĠĠĠĠĠ Ġtransaction al Operator . execute And Await Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfre emark er Mail Sender . generate And Send Link With Token ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprofile . id , ĠTokenType . ACCOUNT _ RE MO VAL , Ġ" Link ToRemove Account . ft lh ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprofile . email , Ġsubject , Ġrequest , Ġ" ÑĥÐ´ Ð°Ð» ÐµÐ½Ð¸Ðµ - Ð¿ ÑĢÐ¾ ÑĦ Ð¸ Ð»Ñı " ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) Ġ{ Ġlink Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġobject Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġtitle Ġ= Ġsubject ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġaction Label Ġ= Ġ" Ð£ Ð´Ð°Ð» ÐµÐ½Ð¸Ðµ ĠÐ¿ÑĢÐ¾ ÑĦ Ð¸ Ð»Ñı " ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġaction Url Ġ= Ġlink ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġmessage Ġ= Ġ" Ðŀ Ð± ÑĢÐ°ÑĤ Ð¸ÑĤÐµ ĠÐ² Ð½ Ð¸Ð¼ Ð°Ð½Ð¸Ðµ ! ĠÐŃ ÑĤÐ¾ ĠÐ´ ÐµÐ¹ ÑģÑĤÐ² Ð¸Ðµ ĠÐ½ ÐµÐ»ÑĮ Ð· Ñı ĠÐ±ÑĥÐ´ÐµÑĤ ĠÐ¾ÑĤ Ð¼ ÐµÐ½Ð¸ ÑĤÑĮ !" ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġreturn Ġok Empty JsonObject () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġsuspend Ġfun Ġremove Profile ( request : ĠServer Request ): ĠServer Response Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdelete Profile Data Ġ= Ġrequest . await Body < Delete Profile Data >() ĊĠĠĠĠĠĠĠ Ġval Ġprincipal Ġ= Ġrequest . await Principal () ĊĊĠĠĠĠĠĠĠ Ġ// Ġverify Ġtoken ĊĠĠĠĠĠĠĠ Ġval Ġcurrent UserProfile Id Ġ= ĠUUID . fromString ( principal !!. name ) ĊĠĠĠĠĠĠĠ Ġval Ġweb Token Ġ= ĠToken ( delete Profile Data . token ). decode () ĊĠĠĠĠĠĠĠ Ġval Ġdb Token Ġ= Ġ( exp iring Token Repository . findById ( web Token . id ) Ġ?: Ġthrow NoSuch Token ()). also Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( it . profile Id Ġ!= Ġcurrent UserProfile Id ) Ġthrow NoSuch Token () Ġ// Ġonly Ġown Ġprofile Ġremoval Ġis Ġallowed ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġdb Token . verify ( web Token . token Value , ĠTokenType . ACCOUNT _ RE MO VAL , Ġpassword Encoder ) ĊĊĠĠĠĠĠĠĠ Ġtransaction al Operator . execute And Await Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ// Ġremove Ġprofile Ġdata ĊĠĠĠĠĠĠĠĠĠĠĠ Ġprofile Evaluation Repository . delete ( currentUser Profile Id ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġactivity Repository . delete ( currentUser Profile Id ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġweight Repository . delete ( currentUser Profile Id ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġheight Repository . delete ( currentUser Profile Id ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġprofile Info Repository . delete ( currentUser Profile Id ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġaccepted Terms Repository . delete ( currentUser Profile Id ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġexp iring Token Repository . delete By Profile Id ( currentUser Profile Id ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġuser Role Repository . delete ( currentUser Profile Id ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlogin Information Repository . delete ( currentUser Profile Id ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġ// Ġremove Ġsecond Ġstage Ġprofile Ġdata ĊĠĠĠĠĠĠĠĠĠĠĠ Ġd ating Profile Info Repository . delete ( currentUser Profile Id ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġuser Pop ulated Local ity Repository . delete ( currentUser Profile Id ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġuser Language Repository . delete ( currentUser Profile Id ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġuser Interest Repository . delete ( currentUser Profile Id ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġuser Personal Quality Repository . delete ( currentUser Profile Id , ĠAtt itude . Lik es ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġuser Personal Quality Repository . delete ( currentUser Profile Id , ĠAtt itude . Dis likes ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġcheck In Repository . delete ( currentUser Profile Id ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdecision Repository . delete ( currentUser Profile Id ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġprofile Impro vement Repository . delete ( currentUser Profile Id ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġprofile Cred ibility Repository . delete ( currentUser Profile Id ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġpair Lock Repository . delete ( D ating Pair Lock ( currentUser Profile Id )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpairs Repository . unlock Other User ( currentUser Profile Id ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġdates Repository . delete Where Second User Is Already Removed ( currentUser Profile Id ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpairs Repository . delete Where Second User Is Already Removed ( currentUser Profile Id ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpairs Repository . deactivate Where Part icip ates ( currentUser Profile Id ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġemail Repository . delete ( currentUser Profile Id ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġhistory Repository . delete Related Profile Views Where Both Users Are Deleted ( currentUser Profile Id ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġhistory Repository . delete Email Changed Events ( currentUser Profile Id ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġ// Ġ+ Ġsave Ġfeedback ĊĠĠĠĠĠĠĠĠĠĠĠ Ġhistory Repository . track Profile Removal Feedback ( currentUser Profile Id , Ġdelete Profile Data . reason , Ġdelete Profile Data . explanation Comment ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ// Ġperform Ġlogout ĊĠĠĠĠĠĠĠ Ġlogout Handler . logout ( Web Filter Exchange ( request . exchange ()) Ġ{ ĠMono . empty () Ġ}, Ġprincipal Ġas ĠAuthentication ). await First OrNull () ĊĊĠĠĠĠĠĠĠ Ġreturn Ġok Empty JsonObject () ĊĠĠĠ Ġ} Ċ }