Returns the name of the first field on the profile model that
    points to the ``auth.User`` model.
763657
def get_profile_user_fieldname(profile_model=None, user_model=None):
    
    Profile = profile_model or get_profile_model()
    User = user_model or get_user_model()
    for field in Profile._meta.fields:
        if field.rel and field.rel.to == User:
            return field.name
    raise ImproperlyConfigured("Value for ACCOUNTS_PROFILE_MODEL does not "
                               "contain a ForeignKey field for auth.User: %s"
                               % Profile.__name__)
94372
@RequestMapping(value = "/profile", method = RequestMethod.GET)
    public String get(Authentication authentication, Model model) {
        Map<String, List<DescribedApproval>> approvals = getCurrentApprovalsForUser(getCurrentUserId());
        Map<String, String> clientNames = getClientNames(approvals);
        model.addAttribute("clientnames", clientNames);
        model.addAttribute("approvals", approvals);
        model.addAttribute("isUaaManagedUser", isUaaManagedUser(authentication));
        return "approvals";
    }
817580
def safe_get_user_model():
    
    user_app, user_model = settings.AUTH_USER_MODEL.split('.')
    return apps.get_registered_model(user_app, user_model)
271065
def get_profile(self):
        
        r = self._session.get(API_URL + "/logins/me")
        r.raise_for_status()

        return r.json()
868142
def get_auto_field_name(self, model_class):
        
        # Get auto field name (a model can only have one AutoField)
        for field in model_class._meta.fields:
            if isinstance(field, AutoField):
                return field.column

        return None
812326
def get_profile_model():
    
    if (not hasattr(settings, 'AUTH_PROFILE_MODULE') or
            not settings.AUTH_PROFILE_MODULE):
        raise SiteProfileNotAvailable

    profile_mod = get_model(*settings.AUTH_PROFILE_MODULE.split('.'))
    if profile_mod is None:
        raise SiteProfileNotAvailable
    return profile_mod
199068
def profile(request, username, template="accounts/account_profile.html",
            extra_context=None):
    
    lookup = {"username__iexact": username, "is_active": True}
    context = {"profile_user": get_object_or_404(User, **lookup)}
    context.update(extra_context or {})
    return TemplateResponse(request, template, context)
1307549
def default(self) -> typing.Optional[Profile]:
        """"""
        found = self.database.execute(
            "SELECT name, data FROM profiles WHERE selected"
            " ORDER BY name LIMIT 1").fetchone()
        if found is None:
            return None
        else:
            state = json.loads(found[1])
            state["name"] = found[0]  # Belt-n-braces.
            return Profile(**state)
1207586
protected String getRenderedUserProfile(final Map<String, Object> model) {
        if (oauthProperties.getUserProfileViewType() == OAuthProperties.UserProfileViewTypes.FLAT) {
            val flattened = new LinkedHashMap<String, Object>();
            if (model.containsKey(MODEL_ATTRIBUTE_ATTRIBUTES)) {
                val attributes = Map.class.cast(model.get(MODEL_ATTRIBUTE_ATTRIBUTES));
                flattened.putAll(attributes);
            }
            model.keySet()
                .stream()
                .filter(k -> !k.equalsIgnoreCase(MODEL_ATTRIBUTE_ATTRIBUTES))
                .forEach(k -> flattened.put(k, model.get(k)));
            LOGGER.trace("Flattened user profile attributes with the final model as [{}]", model);
            return OAuth20Utils.toJson(flattened);
        }
        return OAuth20Utils.toJson(model);

    }
23406
public static function get_fullname_field($firstnamefirst = false) {
        global $DB;
        if ($firstnamefirst) {
            return $DB->sql_fullname(self::resolve_field('firstname', 'user'), self::resolve_field('lastname', 'user'));
        }
        return $DB->sql_fullname(self::resolve_field('lastname', 'user'), self::resolve_field('firstname', 'user'));
    }
440392
def get_profile_for_user(user):
    
    if not hasattr(user, '_yacms_profile'):
        # Raises ProfileNotConfigured if not bool(ACCOUNTS_PROFILE_MODEL)
        profile_model = get_profile_model()
        profile_manager = profile_model._default_manager.using(user._state.db)

        user_field = get_profile_user_fieldname(profile_model, user.__class__)
        profile, created = profile_manager.get_or_create(**{user_field: user})

        profile.user = user
        user._yacms_profile = profile

    return user._yacms_profile
274645
def get_profile_model():
    
    auth_profile_module = getattr(settings, 'AUTH_PROFILE_MODULE', None)
    profile_model = None
    if auth_profile_module:
        # get the profile model. TODO: super flacky, refactor
        app_label, model = auth_profile_module.split('.')
        profile_model = getattr(__import__("%s.models" % app_label, \
                globals(), locals(), [model, ], -1), model, None)

    return profile_model
1350573
def get_profile_model():
    

    if not getattr(settings, "ACCOUNTS_PROFILE_MODEL", None):
        raise ProfileNotConfigured

    try:
        return apps.get_model(settings.ACCOUNTS_PROFILE_MODEL)
    except ValueError:
        raise ImproperlyConfigured("ACCOUNTS_PROFILE_MODEL must be of "
                                   "the form 'app_label.model_name'")
    except LookupError:
        raise ImproperlyConfigured("ACCOUNTS_PROFILE_MODEL refers to "
                                   "model '%s' that has not been installed"
                                   % settings.ACCOUNTS_PROFILE_MODEL)
1308769
private static String getCurrentUserName() {
        Authentication a = SecurityContextHolder.getContext().getAuthentication();
        if (a == null) return null;
        org.springframework.security.core.userdetails.User u =
                (org.springframework.security.core.userdetails.User)
                        a.getPrincipal();
        if (u == null) return null;
        return u.getUsername();
    }
449979
def findUserByVanityName(name)
      method = 'findUser'
      type = User
      args = {:vanityName=>name}
      return_object type,method,args
    end
481395
def get_user_id(self, user):
        
        user_field = getattr(settings, 'SAML_IDP_DJANGO_USERNAME_FIELD', None) or \
                     getattr(user, 'USERNAME_FIELD', 'username')
        return str(getattr(user, user_field))
296351
def profile_name(org_vm, profile_inst, short=False):
    
    try:
        name_tuple = get_profile_name(org_vm, profile_inst)
    except Exception as ex:  # pylint: disable=broad-except
        print('GET_FULL_PROFILE_NAME exception %sm tuple=%r inst=%s' %
              (ex, name_tuple, profile_inst))
        return("UNKNOWN")
    if short:
        return "%s:%s" % (name_tuple[0], name_tuple[1])

    return "%s:%s:%s" % (name_tuple[0], name_tuple[1], name_tuple[2])