Tabnine Logo
LemonReactiveService
Code IndexAdd Tabnine to your IDE (free)

How to use
LemonReactiveService
in
com.naturalprogrammer.spring.lemonreactive

Best Java code snippets using com.naturalprogrammer.spring.lemonreactive.LemonReactiveService (Showing top 13 results out of 315)

origin: naturalprogrammer/spring-lemon

@Override
protected User createAdminUser() {
  
  User user = super.createAdminUser(); 
  user.setName(ADMIN_NAME);
  return user;
}
 
origin: naturalprogrammer/spring-lemon

/**
 * Changes password
 */
@PostMapping("/users/{id}/password")
@ResponseStatus(HttpStatus.NO_CONTENT)
public Mono<Void> changePassword(@PathVariable ID id,
    @RequestBody @Valid Mono<ChangePasswordForm> changePasswordForm,
    ServerHttpResponse response) {
  
  log.debug("Changing password ... ");
  return userWithToken(lemonReactiveService.changePassword(id, changePasswordForm), response).then();
}
origin: naturalprogrammer/spring-lemon

/**
 * Fetch a self-sufficient token with embedded UserDto - for interservice communications
 */
@GetMapping("/fetch-full-token")
public Mono<Map<String, String>> fetchFullToken(@RequestHeader(HttpHeaders.AUTHORIZATION) String authHeader) {
  
  log.debug("Fetching a micro token");
  return lemonReactiveService.fetchFullToken(authHeader);
}    
origin: naturalprogrammer/spring-lemon

@Override
protected void updateUserFields(User user, User updatedUser, UserDto currentUser) {
  super.updateUserFields(user, updatedUser, currentUser);
  user.setName(updatedUser.getName());
}
origin: naturalprogrammer/spring-lemon

/**
 * Returns the context data to be sent to the client,
 * i.e. <code>reCaptchaSiteKey</code> and all the properties
 * prefixed with <code>lemon.shared</code>.
 * 
 * To send custom properties, put those in your application
 * properties in the format <em>lemon.shared.fooBar</em>.
 * 
 * If a user is logged in, it also returns the user data
 * and a new authorization token. If expirationMillis is not provided,
 * the expiration of the new token is set to the default.
 *
 * Override this method if needed.
 */
public Mono<Map<String, Object>> getContext(Optional<Long> expirationMillis, ServerHttpResponse response) {
  
  log.debug("Getting context ...");
  Mono<Optional<UserDto>> userDtoMono = LecrUtils.currentUser();
  return userDtoMono.map(optionalUser -> {
    
    Map<String, Object> context = buildContext();
    optionalUser.ifPresent(user -> {
      addAuthHeader(response, user,
        expirationMillis.orElse(properties.getJwt().getExpirationMillis()));
      context.put("user", user);
    });
    
    return context;			
  });
}
origin: naturalprogrammer/spring-lemon

/**
 * Afgter a successful login, returns the current user with an authorization header.
 */
@PostMapping("/login")
public Mono<UserDto> login(ServerWebExchange exchange) {
  
  log.debug("Returning current user ... ");
  
  return ReactiveSecurityContextHolder.getContext()
      .map(SecurityContext::getAuthentication)
      .map(Authentication::getPrincipal)
      .cast(LemonPrincipal.class)
      .doOnNext(LemonPrincipal::eraseCredentials)
      .map(LemonPrincipal::currentUser)
      .zipWith(exchange.getFormData())
      .doOnNext(tuple -> {                    
        long expirationMillis = lemonReactiveService.getExpirationMillis(tuple.getT2());
        lemonReactiveService.addAuthHeader(exchange.getResponse(), tuple.getT1(), expirationMillis);
      })
      .map(Tuple2::getT1);
}
origin: naturalprogrammer/spring-lemon

/**
 * Fetch a new token - for session sliding, switch user etc.
 */
@PostMapping("/fetch-new-auth-token")
public Mono<Map<String, String>> fetchNewToken(ServerWebExchange exchange) {
  
  log.debug("Fetching a new token ... ");
  
  return lemonReactiveService.fetchNewToken(exchange);
  
  //return LecUtils.mapOf("token", lemonService.fetchNewToken(expirationMillis, username));
}
 
origin: naturalprogrammer/spring-lemon

/**
 * Fetches a user by ID
 */	
@GetMapping("/users/{id}")
public Mono<U> fetchUserById(@PathVariable ID id) {
  
  log.debug("Fetching user: " + id);				
  return lemonReactiveService.fetchUserById(id);
}
origin: naturalprogrammer/spring-lemon

/**
 * Fetches a user by email
 */
@PostMapping("/users/fetch-by-email")
public Mono<U> fetchUserByEmail(ServerWebExchange exchange) {
  
  log.debug("Fetching user by email ... ");						
  return lemonReactiveService.fetchUserByEmail(exchange.getFormData());
}
origin: naturalprogrammer/spring-lemon

/**
 * returns the current user and a new authorization token in the response
 */
public Mono<UserDto> userWithToken(Mono<UserDto> userDto,
    ServerHttpResponse response, long expirationMillis) {
  return userDto.doOnNext(user -> {
    log.debug("Adding auth header for " + user.getUsername());
    addAuthHeader(response, user, expirationMillis);
  });
}
origin: naturalprogrammer/spring-lemon

/**
 * Changes the email
 */
@PostMapping("/users/{userId}/email")
public Mono<UserDto> changeEmail(
    @PathVariable ID userId,
    ServerWebExchange exchange) {
  
  log.debug("Changing email of user ...");
  return userWithToken(lemonReactiveService.changeEmail(
      userId,
      exchange.getFormData()),
    exchange.getResponse());
}
origin: naturalprogrammer/spring-lemon

protected U updateUser(U user, Optional<UserDto> currentUser, String patch) {
  
  log.debug("Updating user: " + user);
  U updatedUser = LecrUtils.applyPatch(user, patch); // create a patched form
  LexUtils.validateBean("updatedUser", updatedUser, UserUtils.UpdateValidation.class).go();
  LecmUtils.ensureCorrectVersion(user, updatedUser);
  
  updateUserFields(user, updatedUser, currentUser.get());
  log.debug("Updated user: " + user);
  return user;
}
 
origin: naturalprogrammer/spring-lemon

public void onStartup() {
  
  userDetailsService
    .findByUsername(properties.getAdmin().getUsername()) // Check if the user already exists
    .doOnError(e -> e instanceof UsernameNotFoundException, e -> {
      // Doesn't exist. So, create it.
      log.debug("Creating first admin ... ");
      U user = createAdminUser();
      userRepository.insert(user).doOnError(err -> {
        log.warn("Error creating initial admin " + err);
      }).subscribe();
      log.debug("Created first admin.");		    	
    }).subscribe();
}
com.naturalprogrammer.spring.lemonreactiveLemonReactiveService

Most used methods

  • createAdminUser
    Creates the initial Admin user. Override this if needed.
  • updateUserFields
    Updates the fields of the users. Override this if you have more fields.
  • addAuthHeader
  • buildContext
  • changeEmail
  • changePassword
  • fetchFullToken
  • fetchNewToken
  • fetchUserByEmail
  • fetchUserById
  • findUserByEmail
  • findUserById
  • findUserByEmail,
  • findUserById,
  • forgotPassword,
  • getContext,
  • getExpirationMillis,
  • mailChangeEmailLink,
  • mailForgotPasswordLink,
  • makeUnverified,
  • newUser,
  • onStartup

Popular in Java

  • Running tasks concurrently on multiple threads
  • getContentResolver (Context)
  • runOnUiThread (Activity)
  • compareTo (BigDecimal)
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • ImageIO (javax.imageio)
  • Notification (javax.management)
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now