package Ġblue jam . h obby . ge k its ui . webapp . controller Ċ Ċ import Ġblue jam . h obby . ge k its ui . webapp . util . GitHub OAuth Fields Ċ import Ġorg . springframework . security . core . context . SecurityContext Holder Ċ import Ġorg . springframework . security . oauth 2 . core . user . OAuth 2 User Ċ import Ġorg . springframework . ui . Model Ċ import Ġorg . springframework . ui . set Ċ import Ġorg . springframework . web . bind . annotation . Controller Ad vice Ċ import Ġorg . springframework . web . bind . annotation . Model Attribute Ċ Ċ @ Controller Ad vice Ċ class ĠUser Controller Ad vice Ġ{ ĊĠĠĠ Ġ@ Model Attribute ĊĠĠĠ Ġfun Ġadd UserName ( model : ĠModel ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġprincipal Ġ= ĠSecurity Context Holder . getContext (). authentication ?. principal ĊĊĠĠĠĠĠĠĠ Ġif Ġ( principal Ġ! is ĠOAuth 2 User ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġmodel [" username "] Ġ= ĠGitHub OAuth Fields . getUser Name ( principal ) Ġ?: Ġthrow ĠException (" GitHub Ġuser Ġdoesn 't Ġhave Ġusername .") ĊĠĠĠ Ġ} Ċ } Ċ