Skip to content
This repository has been archived by the owner on Mar 29, 2021. It is now read-only.

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
Itsusinn奕䜣 committed Nov 17, 2020
1 parent 1ca4fa6 commit 701e41a
Showing 283 changed files with 2,016 additions and 11 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions mychat-backend-spring/depoly.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
gradle clean bootJar
echo Build Successfully
scp -r ./build/libs/mychat.jar itsusinn@atri:/home/itsusinn/
echo Copy Successfully
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -4,9 +4,14 @@ import moe.itsusinn.mychat.security.atri.AtriAuthenticationToken
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.security.core.context.SecurityContextHolder
import org.springframework.security.crypto.bcrypt.BCrypt

fun Any.logger(): Logger = LoggerFactory.getLogger(javaClass)

val Any.credential
get() =
SecurityContextHolder.getContext().authentication as AtriAuthenticationToken
SecurityContextHolder.getContext().authentication as AtriAuthenticationToken

fun checkDbPassword(plaintext:String, hashed:String):Boolean{
return BCrypt.checkpw(plaintext, hashed)
}
Original file line number Diff line number Diff line change
@@ -52,8 +52,8 @@ class UserController {

val user = userService.checkPassword(
username,
bCryptPasswordEncoder.encode(password)
) ?: return UserLoginRespond(Status.Failed, "")
password
) ?: return UserLoginRespond(Status.Failed, "Wrong Password")

val roles = userRoleService.findRolesByUid(user.userID)
val token = generateToken(
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ import org.ktorm.database.Database
import org.ktorm.dsl.eq
import org.ktorm.entity.add
import org.ktorm.entity.find
import org.springframework.security.crypto.bcrypt.BCrypt
import org.springframework.stereotype.Repository

@Repository
@@ -27,4 +28,5 @@ class UserRepository(
*/
fun findUserByUid(uid: Long): UserEntity? = database.users.find { it.userID eq uid }

}
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package moe.itsusinn.mychat.services

import moe.itsusinn.mychat.checkDbPassword
import moe.itsusinn.mychat.repository.UserRepository
import moe.itsusinn.mychat.repository.UserRoleRepository
import moe.itsusinn.mychat.repository.entity.UserEntity
@@ -18,9 +19,13 @@ class UserService {
* 校检密码是否正确
*/
fun checkPassword(username: String, password: String): UserEntity? {
val user = userRepository.findUserByUsername(username)
return if (user == null || user.password != password) null
else user
val userEntity = userRepository.findUserByUsername(username)
return if (
userEntity == null
||
!checkDbPassword(password, userEntity.password)
) null
else userEntity
}

/**
Original file line number Diff line number Diff line change
@@ -3,5 +3,6 @@ spring:
datasource:
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/mychat?useUnicode=true&characterEncoding=utf-8&sessionVariables=sql_mode='NO_ENGINE_SUBSTITUTION'&jdbcCompliantTruncation=false
username: root
type: com.alibaba.druid.pool.DruidDataSource
username: itsusinn
password: X*2Jzh.m;Mrj
type: com.alibaba.druid.pool.DruidDataSource
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ POST http://{{address}}/user/register
Content-Type: application/json

{
"username": "abc",
"username": "abcd",
"password": "123"
}

@@ -17,7 +17,7 @@ POST http://{{address}}/user/login
Content-Type: application/json

{
"username": "abc",
"username": "abcd",
"password": "123"
}
> {% client.global.set("token", response.body.token); %}
11 changes: 11 additions & 0 deletions mychat-backend-vertx/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# EditorConfig is awesome: https://EditorConfig.org

root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
end_of_line = lf
insert_final_newline = true
185 changes: 185 additions & 0 deletions mychat-backend-vertx/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
### Vert.x ###
.vertx/

### Eclipse ###

.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# PyDev specific (Python IDE for Eclipse)
*.pydevproject

# CDT-specific (C/C++ Development Tooling)
.cproject

# Java annotation processor (APT)
.factorypath

# PDT-specific (PHP Development Tools)
.buildpath

# sbteclipse plugin
.target

# Tern plugin
.tern-project

# TeXlipse plugin
.texlipse

# STS (Spring Tool Suite)
.springBeans

# Code Recommenders
.recommenders/

# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet

### Intellij+iml ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries

# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml

# Gradle:
.idea/**/gradle.xml
.idea/**/libraries

# CMake
cmake-buildTool-debug/

# Mongo Explorer plugin:
.idea/**/mongoSettings.xml

## File-based project format:
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-buildTool.properties
fabric.properties

### Intellij+iml Patch ###
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023

*.iml
modules.xml
.idea/misc.xml
*.ipr

### macOS ###
*.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### Maven ###
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties

# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
!/.mvn/wrapper/maven-wrapper.jar

### Gradle ###
.gradle
/buildTool/

# Ignore Gradle GUI config
gradle-app.setting

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

# Cache of project
.gradletasknamecache

# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
# gradle/wrapper/gradle-wrapper.properties

### NetBeans ###
nbproject/private/
buildTool/
nbbuild/
dist/
nbdist/
.nb-gradle/

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
8 changes: 8 additions & 0 deletions mychat-backend-vertx/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions mychat-backend-vertx/.idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions mychat-backend-vertx/.idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions mychat-backend-vertx/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
= Mychat-backend-vertx

image:https://img.shields.io/badge/vert.x-3.9.4-purple.svg[link="https://vertx.io"]

This application was generated using http://start.vertx.io

== Building

To launch your tests:
```
./gradlew clean test
```

To package your application:
```
./gradlew clean assemble
```

To run your application:
```
./gradlew clean run
```

== Help

* https://vertx.io/docs/[Vert.x Documentation]
* https://stackoverflow.com/questions/tagged/vert.x?sort=newest&pageSize=15[Vert.x Stack Overflow]
* https://groups.google.com/forum/?fromgroups#!forum/vertx[Vert.x User Group]
* https://gitter.im/eclipse-vertx/vertx-users[Vert.x Gitter]


Loading
Oops, something went wrong.

0 comments on commit 701e41a

Please sign in to comment.