mirror of
				https://github.com/songquanpeng/one-api.git
				synced 2025-10-27 20:03:42 +08:00 
			
		
		
		
	Compare commits
	
		
			3 Commits
		
	
	
		
			v0.6.7-alp
			...
			v0.5.10-de
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 5df751f5ca | ||
|  | b519170c06 | ||
|  | 3d9ad0024a | 
							
								
								
									
										14
									
								
								.github/workflows/docker-image-amd64.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										14
									
								
								.github/workflows/docker-image-amd64.yml
									
									
									
									
										vendored
									
									
								
							| @@ -9,6 +9,8 @@ on: | ||||
|       name: | ||||
|         description: 'reason' | ||||
|         required: false | ||||
| permissions: | ||||
|   packages: write | ||||
| jobs: | ||||
|   push_to_registries: | ||||
|     name: Push Docker image to multiple registries | ||||
| @@ -25,12 +27,6 @@ jobs: | ||||
|           git describe --tags > VERSION  | ||||
|  | ||||
|       - name: Log in to Docker Hub | ||||
|         uses: docker/login-action@v2 | ||||
|         with: | ||||
|           username: ${{ secrets.DOCKERHUB_USERNAME }} | ||||
|           password: ${{ secrets.DOCKERHUB_TOKEN }} | ||||
|  | ||||
|       - name: Log in to the Container registry | ||||
|         uses: docker/login-action@v2 | ||||
|         with: | ||||
|           registry: ghcr.io | ||||
| @@ -41,9 +37,7 @@ jobs: | ||||
|         id: meta | ||||
|         uses: docker/metadata-action@v4 | ||||
|         with: | ||||
|           images: | | ||||
|             justsong/one-api | ||||
|             ghcr.io/${{ github.repository }} | ||||
|           images: ghcr.io/${{ github.repository }} | ||||
|  | ||||
|       - name: Build and push Docker images | ||||
|         uses: docker/build-push-action@v3 | ||||
| @@ -51,4 +45,4 @@ jobs: | ||||
|           context: . | ||||
|           push: true | ||||
|           tags: ${{ steps.meta.outputs.tags }} | ||||
|           labels: ${{ steps.meta.outputs.labels }} | ||||
|           labels: ${{ steps.meta.outputs.labels }} | ||||
|   | ||||
| @@ -6,14 +6,15 @@ import ( | ||||
| 	"gorm.io/gorm" | ||||
| 	"one-api/common" | ||||
| 	"strings" | ||||
| 	"strconv" | ||||
| ) | ||||
|  | ||||
| // User if you add sensitive fields, don't forget to clean them in setupLogin function. | ||||
| // Otherwise, the sensitive information will be saved on local storage in plain text! | ||||
| type User struct { | ||||
| 	Id               int    `json:"id"` | ||||
| 	Username         string `json:"username" gorm:"unique;index" validate:"max=12"` | ||||
| 	Password         string `json:"password" gorm:"not null;" validate:"min=8,max=20"` | ||||
| 	Username         string `json:"username" gorm:"unique;index" validate:"max=30"` | ||||
| 	Password         string `json:"password" gorm:"not null;" validate:"min=8,max=30"` | ||||
| 	DisplayName      string `json:"display_name" gorm:"index" validate:"max=20"` | ||||
| 	Role             int    `json:"role" gorm:"type:int;default:1"`   // admin, common | ||||
| 	Status           int    `json:"status" gorm:"type:int;default:1"` // enabled, disabled | ||||
| @@ -42,7 +43,12 @@ func GetAllUsers(startIdx int, num int) (users []*User, err error) { | ||||
| } | ||||
|  | ||||
| func SearchUsers(keyword string) (users []*User, err error) { | ||||
| 	err = DB.Omit("password").Where("id = ? or username LIKE ? or email LIKE ? or display_name LIKE ?", keyword, keyword+"%", keyword+"%", keyword+"%").Find(&users).Error | ||||
| 	if uid, ok := strconv.Atoi(keyword); ok == nil { | ||||
| 		err = DB.Omit("password").Where("id = ? or username LIKE ? or email LIKE ? or display_name LIKE ?", uid, keyword+"%", keyword+"%", keyword+"%").Find(&users).Error | ||||
| 	} else { | ||||
| 		err = DB.Omit("password").Where("username LIKE ? or email LIKE ? or display_name LIKE ?", keyword+"%", keyword+"%", keyword+"%").Find(&users).Error | ||||
| 	} | ||||
|  | ||||
| 	return users, err | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user